Vitali
04/26/2022, 2:21 PMnit
-
customMetadata: {
'content-length': response.headers?.get('content-length'),
},
is redundant. The size of the file is already stored by us for free (see the .size
member variable beside .customMetadata
in R2Object
).vasco-santos
04/26/2022, 2:23 PMConnected! Streaming logs from nftstorage-link-api-staging... (ctrl-c to quit)
{"outcome":"ok","scriptName":null,"exceptions":[],"logs":[{"message":[{}],"level":"log","timestamp":1650982992419},{"message":["header","23"],"level":"log","timestamp":1650982992675},{"message":["[2022-04-26T14:23:12.675Z] ","name: 1307 ms"],"level":"log","timestamp":1650982992675},{"message":["TypeError: The value cannot be converted because it is not an integer.\n
header","23" per console.log('header', response.headers.get('content-length'))
vasco-santos
04/26/2022, 2:24 PMVitali
04/26/2022, 2:31 PMR2.put
that's throwing the exception and not something else?vasco-santos
04/26/2022, 2:36 PMconst response = await getResponse(request, env, normalizedUrl)
if (!response.ok) {
throw new HTTPError(await response.text(), 400)
}
console.log('pre put log', normalizedUrl.toString())
r2Object = await env.SUPERHOT.put(normalizedUrl.toString(), response.body)
console.log('post put log')
And called it with tail on
Connected! Streaming logs from nftstorage-link-api-staging... (ctrl-c to quit)
{"outcome":"ok","scriptName":null,"exceptions":[],"logs":[{"message":[{}],"level":"log","timestamp":1650983696930},{"message":["pre put log","https://bafkreidyeivj7adnnac6ljvzj2e3rd5xdw3revw4da7mx2ckrstapoupoq.ipfs.nftstorage.link/"],"level":"log","timestamp":1650983697103},{"message":["[2022-04-26T14:34:57.103Z] ","name: 1177 ms"],"level":"log","timestamp":1650983697103},{"message":["TypeError: The value cannot be converted because it is not an integer.\n at permaCachePut (worker.js:3883:35)\n
worker.js line is the put line + no post put logVitali
04/26/2022, 2:43 PMtry/catch
around the SUPERHOT.put
and log from within the catch just to be extra sure?vasco-santos
04/26/2022, 2:50 PM`
console.log('pre put log', normalizedUrl.toString())
try {
r2Object = await env.SUPERHOT.put(normalizedUrl.toString(), response.body)
} catch (err) {
console.log('err', String(err))
throw err
}
console.log('post put log')
`
`
Connected! Streaming logs from nftstorage-link-api-staging... (ctrl-c to quit)
{"outcome":"ok","scriptName":null,"exceptions":[],"logs":[{"message":[{}],"level":"log","timestamp":1650984564376},{"message":["pre put log","https://bafkreidyeivj7adnnac6ljvzj2e3rd5xdw3revw4da7mx2ckrstapoupoq.ipfs.nftstorage.link/"],"level":"log","timestamp":1650984564449},{"message":["err","TypeError: The value cannot be converted because it is not an integer."],"level":"log","timestamp":1650984564449},
Vitali
04/26/2022, 3:04 PMjohn.spurlock
04/26/2022, 3:17 PMCopyObject
work yet? I'm sending the x-amz-copy-source: /<bucket>/<key>
header, but getting a 400 Invalid Argument: copy source bucket name error back from r2. The source bucket is the same as the target bucket (same error when target bucket is different than source)john.spurlock
04/26/2022, 3:26 PMCopyObject
.
Also the success response content-type should be application/xml
, not text/plain;charset=UTF-8
Also copies to a bucket that does not exist fail with 500 internal error, not some 4xx error.vasco-santos
04/26/2022, 3:26 PMypeError: The value cannot be converted because it is not an integer.
and should be easier on your side to test with README instructionsVitali
04/26/2022, 3:29 PMVitali
04/26/2022, 3:30 PMVitali
04/26/2022, 3:35 PMjohn.spurlock
04/26/2022, 3:39 PMVitali
04/26/2022, 3:39 PMjohn.spurlock
04/26/2022, 3:41 PMQuiet
parameter to DeleteObjects
is ignored/not-implemented, deleted keys are included in the response no matter the valueVitali
04/26/2022, 3:43 PMVitali
04/26/2022, 3:43 PMjohn.spurlock
04/26/2022, 3:45 PM<Delete xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<Object>
<Key>a</Key>
</Object>
<Object>
<Key>b</Key>
</Object>
<Object>
<Key>c</Key>
</Object>
<Quiet>true</Quiet>
</Delete>
Vitali
04/26/2022, 3:46 PMjohn.spurlock
04/26/2022, 3:48 PMVitali
04/26/2022, 4:00 PMconst xml = '<Delete><Quiet>true</Quiet></Delete>'
expect(
fromXML(
xml,
z.object({ Delete: z.object({ Quiet: z.boolean().optional() }) }),
).val,
).toEqual({
Delete: {
Quiet: true,
},
})
That passes and that's roughly the schema we use. Our e2e tests use the official amazon JS SDK (v2 though). What are you using?john.spurlock
04/26/2022, 4:05 PMVitali
04/26/2022, 4:10 PMconst deletedKeys: DeleteObjectsResultItem[] = quietMode
? []
: resp.val.toDelete.map((d) => {
return { key: d.object }
})
<snip error mapping>
return ok([...deletedKeys, ...errors])
We definitely have this logic....Vitali
04/26/2022, 4:13 PMconst res = await sync(
s3.deleteObjects({
Bucket: bucketName,
Delete: {
Objects: [{ Key: 'fish1.jpeg' }, { Key: 'fish2.jpeg' }],
Quiet: true,
},
}),
)
expect(res.Deleted?.length).toBe(0)
expect(res.Errors?.length).toBe(0)
Vitali
04/26/2022, 4:13 PMstupefied | AS204829
04/26/2022, 4:17 PMIsaac McFadyen | YYZ01
04/26/2022, 4:25 PMIsaac McFadyen | YYZ01
04/26/2022, 4:26 PM