Comments (6)
Actually no -- just double-checked and the behavior here appears to have changed. We used to tell you "not seekable, can't do it", but now it looks like a pure Reader implementation causes us to not set content-length, which does in fact result in that exact error you've given. That is much worse than what we did before. Reopening.
from aws-sdk-go-v2.
SDK operation returns a 501, api error NotImplemented: A header you provided implies functionality that is not implemented
FYI this is unrelated. The error you get when using a non-seekable body is going to be different (we're going to detect that and return it as an error before even sending the request).
This is a known pain point as you've indicated, I'm going to spawn a dedicated issue for tracking.
EDIT: jk, read on
from aws-sdk-go-v2.
Trivially reproducible:
package main
import (
"context"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/service/s3"
)
type reader []byte
func (r reader) Read(p []byte) (n int, err error) {
copy(p, r)
return len(r), nil
}
func (r reader) Seek(offset int64, whence int) (int64, error) {
return 0, nil
}
func main() {
cfg, err := config.LoadDefaultConfig(context.Background())
if err != nil {
panic(err)
}
svc := s3.NewFromConfig(cfg, func(o *s3.Options) {
o.ClientLogMode = aws.LogRequest
})
_, err = svc.PutObject(context.Background(), &s3.PutObjectInput{
Bucket: aws.String("bucket"),
Key: aws.String("key"),
Body: reader("foo"),
})
if err != nil {
panic(err)
}
}
If you make this request as-is, it will succeed. If you remove the Seek
implementation from reader
, we will not set content-length and thus the request will fail with a 501 (at least that's what S3 does - other services may behave differently).
from aws-sdk-go-v2.
@ivanshiras note that if you're streaming from another S3 response (or you know the content length yourself some other way), you can get around this by just setting ContentLength
on the input directly (hardcoded in this example, but you'd pass it in from the response etc.):
package main
import (
"context"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/service/s3"
)
type reader []byte
func (r reader) Read(p []byte) (n int, err error) {
copy(p, r)
return len(r), nil
}
// no seek
func main() {
cfg, err := config.LoadDefaultConfig(context.Background())
if err != nil {
panic(err)
}
svc := s3.NewFromConfig(cfg, func(o *s3.Options) {
o.ClientLogMode = aws.LogRequest
})
_, err = svc.PutObject(context.Background(), &s3.PutObjectInput{
Bucket: aws.String("bucket"),
Key: aws.String("key"),
Body: reader("foo"),
ContentLength: aws.Int64(3),
})
if err != nil {
panic(err)
}
}
from aws-sdk-go-v2.
@ivanshiras note that if you're streaming from another S3 response (or you know the content length yourself some other way), you can get around this by just setting
ContentLength
on the input directly (hardcoded in this example, but you'd pass it in from the response etc.):
Thanks Luc, I switched to the using the S3 manager Uploader which doesn't have the issue and has some performance benefits where I don't need to parse the response into memory and/or disk before uploading.
from aws-sdk-go-v2.
This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.
from aws-sdk-go-v2.
Related Issues (20)
- Customize S3's "Expires" field to handle invalid timestamps HOT 1
- S3 client falling over after 4-5 hours of processing 200 files per minute HOT 5
- Add support for Prometheus compatible APIs in amp service HOT 4
- Control Tower Landing Zone manifest retentionDays unmarshalled into string instead of number HOT 4
- Support for paginators in the apigatewayv2 service HOT 2
- Unexpected error type returned for DescribeDBClusterParameterGroups HOT 4
- Incorrect S3 object key(Path) Handling for domainStyle HOT 4
- InferenceConfiguration godoc has random data pasted in HOT 2
- Add support to create git tags HOT 2
- Support KRaft mode for MSK HOT 3
- Duplicate Go Pkg Docs HOT 2
- sts PresignGetCallerIdentity - make it simpler to add custom HTTP headers HOT 1
- MIGRATION ISSUE: EC2 AttachmentStatus has improper values HOT 3
- RestoreDbInstanceFromDbSnapshot fails when SCP policy for encryption exists HOT 2
- operation inputs with streaming blobs are typed as io.Reader but sigv4 requires seekable bodies for payload calculation HOT 2
- Global `UseFIPSEndpoint` setting and Assuming IAM Role from shared config file HOT 9
- Unable to use apigatewaymanagementapi using sdk v2 1.19.11 HOT 2
- config.LoadDefaultConfig(context.Background(), config.WithRegion(defaultRegion) -- returns cfg.Credentials == Nil HOT 3
- support item op for Dax client HOT 2
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-go-v2.