Comments (3)
Thank you very much for providing such an easy-to-use repro case. :)
When filling the MemoryStream, you are not resetting the position to the start of the stream. If you call ms.Position = 0; before constructing the request, the position will reset and the request will succeed. V1 SDK did this, while the V2 SDK does not.
But setting the position is not the only possible solution:
- Since you already have a FileStream with your data, you can simply set the PutObjectRequest.InputStream to that stream.
- You can also construct the MemoryStream by passing in a byte array of your data (this would allow you to keep the file open for the shortest possible time). This can be done either by reading the data as you are doing it, or with File.ReadAllBytes.
On an unrelated note, when you are creating an instance of AmazonS3Config you are setting both ServiceURL and RegionEndpoint. You only need to set one of these. (If ServiceURL is set, the SDK ignores RegionEndpoint.) For ease of use, however, I would recommend to just using the RegionEndpoint.
from aws-sdk-net.
Wow, thanks for an amazing, quick and right response!
Yep, reset of stream position helps and now console app works too :)
Secret was that in ASP.NET MVC app I do that, however in console app I read data other way (more simple) and fail with it.
I however want to make following notes: think it's good idea to list that (i.e. fact that new version of SDK does not reset stream position anymore) as breaking change because some other developers may step at the same issue (agree however that correct way to remove that line from SDK source code because it's client responsibility to ensure correct position in the stream... i.e. was totally my fault)
Thanks also for Tips about handing of streams for short period of time (they are correct and sample application can be improved with them, however in my production code it's more complicated and optimized already... for example I use async reading from source stream opened from web response instead of file in filesystem etc)
Re: ServiceUrl and RegionEndpoint I just can't found any info and decide to use both :D Now it's clear, thanks!
Thanks again, Amazing work!
🍻
from aws-sdk-net.
Hi @PavelSafronov!
Would be amazing if you can take a look into new issue #27 for which same projects with SDK v2 have issues with Content-Encoding headers :)
Thanks!
P.S. hopefully last issue I need to be fixed in v2 to put my site latest version live :)
from aws-sdk-net.
Related Issues (20)
- Avoid StringBuilder.AppendFormat HOT 5
- Avoid creating unnecessary intermediate strings HOT 5
- Migrating from .Net 6 to .Net 8 HOT 4
- Using the SDK in web application testing broken (.NET 8 URI canonicalization) HOT 6
- Using SSO in .NET Core with Docker Compose HOT 7
- Amazon.S3.Transfer TransferUtility.UploadAsync() throwing exception under .Net 8 with latest MS and AWS SDK NuGet packages HOT 6
- Critical DateTime to Epoch serialization issue for DynamoDb when date is beyond epoch supported date HOT 2
- Missing Models for SES HOT 5
- Switch .net 472 version of SDK to use HttpClient instead of HttpWebRequest HOT 4
- Support conditional put in TransferUtility (S3) HOT 2
- Add option to AWSConfigs to only use ec2 instance profile role for AWSCredentials HOT 2
- Clock skew correction causes repeated retries HOT 6
- v4 HttpPipeline ReadOnlyMemory
- It is not possible to remove TableNamePrefix via DynamoDBOperationConfig HOT 5
- AWSSDK.Core Could Not load from assembly GAC issues HOT 5
- Native AOT support for DynamoDB HOT 2
- Unable to configure S3 Client when using DynamoDB S3Link HOT 2
- Consider adding resolving basic credentials from configuration in AWSSDK.Extensions.NETCore.Setup HOT 6
- Consider adding TryAddDefaultAWSOptions to AWSSDK.Extensions.NETCore.Setup HOT 4
- ignore HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aws-sdk-net.