.Net SDK upload file API, requires that the stream must be seek able and support Length property

0

I have a .NET web application that receives a stream over http from a client. The stream received from the client does not support the Length or Seek functionality. I need to upload this stream to S3. Therefore I am using the .net SDK https://www.nuget.org/packages/AWSSDK.S3/3.7.102 According to the documentation from AWS S3 RestAPI, it seems that the length and seek functionality is not required: https://docs.aws.amazon.com/AmazonS3/latest/API/API_UploadPart.html On this above link, the required parameters are marked with "Required: yes", but for "Content-Length", there is no requirement. I am using "UploadPartRequest" and "PutObjectRequest" but both of these requests do not work even by setting following parameters: DisablePayloadSigning = true, DisableMD5Stream = true, CalculateContentMD5Header = false, UseChunkEncoding = false,

Could you please check this problem and fix it in SDK because without this fix, I must download the stream from client in an intermediate stream and must face a performance issues. Thanks.

niaz
asked a year ago481 views
4 Answers
0

Hi, @niaz.

Could you please check this problem and fix it in SDK

You want to report a bug instead of asking a question?
We can still have a discussion here, but perhaps it would be better to add the product team to the conversation.

The AWS SDK for .NET is issue and version managed on GitHub and the .NET on AWS team is participating.

https://github.com/dotnet/sdk

You can contribute to a quick fix by filing a bug report here.

Additionally, the AWS Developers Slack has a .NET on AWS channel, so we can discuss improvements there as well.

https://twitter.com/dotnetonAWS/status/1620180080377925632?s=20

profile picture
EXPERT
iwasa
answered a year ago
0

Hello, First I want to know if the documentation is correct or I am understanding it wrong. What should be the expected behavior from the Upload API. If you could please first make sure the expected behavior then I can submit a bug request. So the question is: Do I need the length and seek capability of the stream when I call PUT to upload an object with stream?

Thanks

niaz
answered a year ago
0

@niaz,

Based on your description you want to pass through a file received over HTTP to S3. Naturally, seeking will not be supported because you are receiving a NetworkStream which streams content in chunks. The entire stream does not arrive at the client all at once. The Stream or NetworkStream object may not support reporting its length, but you can still determine the length. Your HTTP client will have received the Content-Length header and that will tell you the length of the stream. If absolutely necessary, you could wrap the stream with a custom Stream implementation that has the length from Content-Length and passes through all other operations to the original stream.

The UploadPart API is for using a MIME-encoded, multipart documentation which is necessary send multiple files at once. Are you trying to send multiple, received files? Your description makes no mention of that. If you're not sending multiple files, why not just use PutObject?

AWS
Chris M
answered a year ago
0

Thanks for the answer.

A wrap stream like you wrote with Content-Length can be used, but this is unfortunately not possible. In some situations, our client does not provide the "Content-Length" to the Web API. The only solution then I see is the intermediate cache. Therefore I asked, if the "Content-Length" property is really required by S3 RestAPI, if not then I can add a bug report for .net SDK.

The other thing related to Seek, there seems to be a bug for multipart upload but the simple object upload works. I have downloaded the code of .net SDK and debugged a bit, this bug I will report.

Yes, we do use multi-part upload. In this case again the client decides, if a stream can contain the length or not. Under normal conditions, the multiple parts of the same file are uploaded simultaneously and the "Content-Length" is also available for me on the server. But in order to use this property I need to change the existing code and all the interfaces...

Thanks,

niaz
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions