taylorfinnell / awscr-s3

A Crystal shard for S3.
https://taylorfinnell.github.io/awscr-s3/
MIT License
81 stars 48 forks source link

Multipart fails with XAmzContentSHA256Mismatch #96

Closed snadon closed 3 years ago

snadon commented 3 years ago

I'm upgrading a project to lucky 0.27.2, crystal 1.0.0 and aswscr-s3 0.8.2 (from 0.8.0).

Previously, all files were uploading to s3 without any problems.

Since my upgrade files greater than 5MB do not upload.

My code:

client = Awscr::S3::Client.new(ENV.fetch("AWS_ACCESS_REGION"), ENV.fetch("AWS_ACCESS_KEY"), ENV.fetch("AWS_SECRET_KEY"))
uploader = Awscr::S3::FileUploader.new(client)
File.open(File.expand_path(path), "r") do |file|
    path = uploader.upload(ENV.fetch("AWS_BUCKET_NAME"), filename, file, {"x-amz-acl" => "public-read"})
end

File smaller than 5MB (single request works):

9:44:15 PM web.1          |  file # => #<File:/var/folders/55/y42kx6yj78q75hh7z_dypf7h0000gn/T/.W8eN9gfile>
9:44:15 PM web.1          |   ▸ Performing request
9:44:16 PM web.1          |   ▸ Sent 200 OK (786.2ms)

File bigger than 5MB (multipart fails):

9:40:38 PM web.1          |  file # => #<File:/var/folders/55/y42kx6yj78q75hh7z_dypf7h0000gn/T/.5H2kXrfile>
9:40:38 PM web.1          |   ▸ Performing request
9:40:38 PM web.1          |   ▸ Performing request
9:40:38 PM web.1          |   ▸ Performing request
9:40:38 PM web.1          |   ▸ Performing request
9:40:38 PM web.1          |   ▸ Performing request
9:40:39 PM web.1          |  Unhandled exception in spawn: XAmzContentSHA256Mismatch: The provided 'x-amz-content-sha256' header does not match what was computed. (Awscr::S3::Exception)
9:40:39 PM web.1          |    from lib/awscr-s3/src/awscr-s3/http.cr:114:9 in 'handle_response!'
9:40:39 PM web.1          |    from lib/awscr-s3/src/awscr-s3/http.cr:88:16 in 'exec'
9:40:39 PM web.1          |    from lib/awscr-s3/src/awscr-s3/http.cr:46:7 in 'put'
9:40:39 PM web.1          |    from lib/awscr-s3/src/awscr-s3/client.cr:111:14 in 'upload_part'
9:40:39 PM web.1          |    from lib/awscr-s3/src/awscr-s3/multipart_file_uploader.cr:87:17 in 'upload_part'
9:40:39 PM web.1          |    from lib/awscr-s3/src/awscr-s3/multipart_file_uploader.cr:80:9 in '->'
9:40:39 PM web.1          |    from /usr/local/Cellar/crystal/1.0.0/src/primitives.cr:255:3 in 'run'
9:40:39 PM web.1          |    from /usr/local/Cellar/crystal/1.0.0/src/fiber.cr:92:34 in '->'
9:40:41 PM web.1          |  Unhandled exception in spawn: XAmzContentSHA256Mismatch: The provided 'x-amz-content-sha256' header does not match what was computed. (Awscr::S3::Exception)
9:40:41 PM web.1          |    from lib/awscr-s3/src/awscr-s3/http.cr:114:9 in 'handle_response!'
9:40:41 PM web.1          |    from lib/awscr-s3/src/awscr-s3/http.cr:88:16 in 'exec'
9:40:41 PM web.1          |    from lib/awscr-s3/src/awscr-s3/http.cr:46:7 in 'put'
9:40:41 PM web.1          |    from lib/awscr-s3/src/awscr-s3/client.cr:111:14 in 'upload_part'
9:40:41 PM web.1          |    from lib/awscr-s3/src/awscr-s3/multipart_file_uploader.cr:87:17 in 'upload_part'
9:40:41 PM web.1          |    from lib/awscr-s3/src/awscr-s3/multipart_file_uploader.cr:80:9 in '->'
9:40:41 PM web.1          |    from /usr/local/Cellar/crystal/1.0.0/src/primitives.cr:255:3 in 'run'
9:40:41 PM web.1          |    from /usr/local/Cellar/crystal/1.0.0/src/fiber.cr:92:34 in '->'
9:40:41 PM web.1          |   ▸ Performing request
9:40:41 PM web.1          |   ▸ The XML you provided was not well-formed or did not validate against our published schema
stakach commented 3 years ago

this is also resolved now with #103