-
Notifications
You must be signed in to change notification settings - Fork 557
Closed
Labels
typesRelated to @cloudflare/workers-typesRelated to @cloudflare/workers-types
Description
Previously (workers-types@4.20240529.0), R2 checksums were defined like this:
declare interface R2Checksums {
readonly md5?: ArrayBuffer;
readonly sha1?: ArrayBuffer;
readonly sha256?: ArrayBuffer;
readonly sha384?: ArrayBuffer;
readonly sha512?: ArrayBuffer;
toJSON(): R2StringChecksums;
}which meant code like this (pseudo) was perfectly valid:
const file = await env.MY_BUCKET.get('file.txt');
let checksum: ArrayBuffer | null = null;
if(file?.checksums?.md5){
checksum = file.checksums.md5.slice(0, 8); // not really how this would work, but illustrates the change
}Now (workers-types@4.20240603.0), it's defined like this:
declare interface R2Checksums {
readonly md5?: ArrayBufferView;
readonly sha1?: ArrayBufferView;
readonly sha256?: ArrayBufferView;
readonly sha384?: ArrayBufferView;
readonly sha512?: ArrayBufferView;
toJSON(): R2StringChecksums;
}which implies you have to do .buffer on each of the checksums to access it, like:
checksum = file.checksums.md5.buffer.slice(0, 8);but this then throws a TypeError: TypeError: Cannot read properties of undefined (reading 'slice')
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
typesRelated to @cloudflare/workers-typesRelated to @cloudflare/workers-types
Type
Projects
Status
Done