Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Object Copy does not work #30

Closed
Sparragus opened this issue Feb 16, 2016 · 0 comments
Closed

Object Copy does not work #30

Sparragus opened this issue Feb 16, 2016 · 0 comments

Comments

@Sparragus
Copy link
Contributor

Sorry for the click-bait issue name. Object Copy does work, but read on and see what I mean.

I've been having a discussion over at aws/aws-sdk-js#901 regarding their documentation on s3.copyObject(...). In the same document where x-amz-copy-source is specified, there are conflicting descriptions on how it should be set.

AWS Documentation

The 'Syntax' section of the documentation says:

x-amz-copy-source: /source_bucket/sourceObject

However, in the 'Request Headers' section, the documentation says:

Name:
   x-amz-copy-source
Description:
   The name of the source bucket and key name of the source object, separated by a slash (/).

   Type: String

   Default: None
Required:
   Yes

So, which one should be followed?

  1. '/' + bucketName + '/' + keyName
  2. bucketName + '/' + keyName

What s3rver does

s3rver expects x-amz-copy-source: /source_bucket/sourceObject. See lib/controllers.js#L264-L268.

Without the initial '/', srcBucket = srcObjectParams[1] ends up being the source object's key. Eventually this will fail with a

error: No bucket found for "image.png"
info: PUT /BUCKET_NAME/image.copy.png 404 207 - 60.642 ms

What should we do?

I think that in the mean time we should do something to accept both forms. Otherwise integration with other libraries fail. s3fs is an example. See s3fs/lib/s3fs.js#L345 (It does not use an initial '/')

However, I invite you all to participate on the discussion over at aws/aws-sdk-js#901.

Sparragus added a commit to Sparragus/s3rver that referenced this issue Feb 16, 2016
Fixes jamhall#30

Since S3's documentation is ambiguous, `s3rver` should expect both versions of `x-amz-copy-source`. This change adds a '/' to `copy` in case `x-amz-copy-source` does not have a leading '/'.

For S3's documentation, see https://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectCOPY.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant