- Newest
- Most votes
- Most comments
Warm Greetings,
I understand you are receiving the error "A header you provided implies functionality that is not implemented" when trying to upload a file from Lambda to a pre-signed S3 URL.
This is a 501 Server Error[1]. While this error isn't the most descriptive, there are a few things we can try. These mostly revolve around the request itself.
A few situations that can cause this error: [+] The 'Content-Length' header is missing and should be added in the request. [+] Confirm that the request content is not empty. [+] Convert the Stream to a Buffer (or string) and pass as the body.
I would also recommend updating the AWS SDK.Core version to the latest release in the case that a bug is present with this version. The latest release is 3.7.105.8 [2].
As this error may require further investigation and the sharing of account-information, I recommend creating a technical support case[3] with AWS Premium Support and they will gladly assist further.
For further testing purposes, I will be leaving the example .NET SDK implementation for uploading an object to a pre-signed URL here[4].
I have reviewed the documentation[5] for the .NET SDK and the PutObject method. A workaround to the issue might be to use the AWS SDK and S3 client to send the Stream, without the need for a pre-signed URL. If this is suitable for your use-case, see the example code for using the PutObject method with a Stream:
==========================
// Create a client
AmazonS3Client client = new AmazonS3Client();
// Create a PutObject request
PutObjectRequest request = new PutObjectRequest
{
BucketName = "SampleBucket",
Key = "Item1",
};
using (FileStream stream = new FileStream("contents.txt", FileMode.Open))
{
request.InputStream = stream;
// Put object
PutObjectResponse response = client.PutObject(request);
}
==========================
Take care and have a great week ahead!
Resources: [1] https://docs.aws.amazon.com/AmazonS3/latest/API/ErrorResponses.html#ErrorCodeList [2] https://www.nuget.org/packages/AWSSDK.Core/#versions-body-tab [3] https://console.aws.amazon.com/support/home#/case/create [4] https://docs.aws.amazon.com/AmazonS3/latest/userguide/PresignedUrlUploadObject.html#generating-presigned-url [5] https://docs.aws.amazon.com/sdkfornet1/latest/apidocs/html/M_Amazon_S3_AmazonS3_PutObject.htm
Thank you James for your response, we need to use presigned URL for uploading large file with size exceeds 6 MB. Adding the 'Content-Length' header caused another issue "System.NotSupportedException: Specified method is not supported. at System.Net.Http.HttpBaseStream.get_Length(), when the sending file to presigned URL is executed inside the lambda function.
I did create a support case at AWS support center couple weeks ago, working with AWS support engineers online for several times, but so far no solution yet
Thanks Kebin
Relevant content
- asked 9 months ago
- AWS OFFICIALUpdated 7 months ago
- AWS OFFICIALUpdated 10 months ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 10 months ago