Vitali
05/05/2022, 12:50 PMalbert
05/05/2022, 1:22 PMVitali
05/05/2022, 2:01 PMncw
05/05/2022, 2:25 PMencoding-type
in the URL: see https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html#AmazonS3-ListObjectsV2-request-querystring-EncodingType
S3 didn't used to have encoding-type
(it was introduced in November 2013) and it was introduced to fix this problem.
If I try the same tests with S3 I get the same result - without encoding-type
I get an embedded \r
which doesn't parse right, with encoding-type=url
it works fine.
So R2 is 100% compatible with AWS S3 as far as control characters in ListObjects goes.albert
05/05/2022, 2:39 PMmjs
// Create multipart
const multipart = await env.R2.createMultipart('some_key', {customMetadata: {'Hello': 'World'}}) // Same options as normal PUT
const uploadId = multipart.uploadId
return new Response(uploadId)
// Upload part
const multipart = env.R2.getMultipart(uploadId)
await multipart.uploadPart(1, request.body)
// Delete
const multipart = env.R2.getMultipart(uploadId)
await multipart.cancel()
// List parts
const multipart = env.R2.getMultipart(uploadId)
const parts = await multipart.listParts()
return new Response(JSON.stringify(parts))
// Complete multipart
const metadata = await multipart.finish() // Returns the same info as a normal PUT would
return new Response(JSON.stringify(metadata))
Vitali
05/05/2022, 2:48 PMVitali
05/05/2022, 2:49 PMalbert
05/05/2022, 2:54 PMVitali
05/05/2022, 2:55 PMIsaac McFadyen | YYZ01
05/05/2022, 2:56 PMalbert
05/05/2022, 2:56 PMVitali
05/05/2022, 2:57 PMVitali
05/05/2022, 3:02 PM/
issue should be fixed now.ncw
05/05/2022, 3:25 PMEtag: "d41a85febcd14e479493bc112efc2b57"
Wheras AWS S3 would return one like this where the -3
on the end indicates a multpart upload of 3 parts
Etag: "d41a85febcd14e479493bc112efc2b57-3"
Rclone is perfectly happy with etags like R2 is returning but they must be the MD5SUM of the object if they are returned in that form.
It seems from my tests with multipart uploads that the ETag
isn't always the MD5SUM of the object (or maybe never is - not quite sure).
Rclone uploads the parts of multipart uploads in parallel which is going to make calculating the MD5SUM for the entire object difficult (which is why AWS don't bother).
So I think R2 should either make the Etag
match the MD5SUM of the object for multipart uploads or make it match what AWS does: [here is the bit of code in rclone which calculates an AWS multipart Etag for checking the upload](https://github.com/rclone/rclone/blob/a446106041fb9b5b57bdbb5e279bb8b64079f100/backend/s3/s3.go#L3969-L3970)Vitali
05/05/2022, 3:26 PMVitali
05/05/2022, 3:26 PMVitali
05/05/2022, 3:27 PMVitali
05/05/2022, 3:28 PMncw
05/05/2022, 3:33 PMVitali
05/05/2022, 3:35 PMncw
05/05/2022, 3:36 PMVitali
05/05/2022, 3:36 PMVitali
05/05/2022, 3:38 PMncw
05/05/2022, 3:39 PMVitali
05/05/2022, 3:40 PMadaptive
05/05/2022, 3:43 PMErisa | Support Engineer
05/05/2022, 4:02 PMadaptive
05/05/2022, 4:04 PMJames
05/05/2022, 4:09 PMhttpMetadata
(assuming available when you put
), so you can do stuff like this: https://github.com/Cherry/ShareX-R2-Cloudflare-Workers/blob/5934cc77dc24e29e677dd3ff8b9edfebfe83bd93/src/routes.mjs#L122Erisa | Support Engineer
05/05/2022, 4:12 PM