Jakub Kaniewski
Test
Jakub Kaniewski
Test
Test
Luan Trasel
1
test
Jakub Kaniewski
Bold
Italic
Underline
URL
- 1
- 2
- 3
- a
- b
- c
export async function main() {
console.log('Running scheduled app')
const part1 = new Uint8Array(5 * 1024 * 1024)
const part2 = new Uint8Array([1, 2, 3, 4, 5])
part1.fill(97) // "a"
async function* fileStream() {
yield part1
yield part2
}
const file = await storage.uploadStream(fileStream(), {
contentType: 'application/octet-stream',
expiresInSeconds: 3600,
contentDisposition: 'attachment; filename="multipart-test.bin"',
})
const response = await fetch(file.url)
if (!response.ok) {
throw new Error(`Download failed with ${response.status} ${response.statusText}`)
}
const downloaded = new Uint8Array(await response.arrayBuffer())
const expectedLength = part1.byteLength + part2.byteLength
if (downloaded.byteLength !== expectedLength) {
throw new Error(`Wrong size: got ${downloaded.byteLength}, expected ${expectedLength}`)
}
for (let index = 0; index < part1.byteLength; index += 1) {
if (downloaded[inde😆 !== part1[index]) {
throw new Error(`Part 1 mismatch at byte ${index}`)
}
}
for (let index = 0; index < part2.byteLength; index += 1) {
const downloadedIndex = part1.byteLength + index
if (downloaded[downloadedInde😆 !== part2[index]) {
throw new Error(`Part 2 mismatch at byte ${downloadedIndex}`)
}
}
console.log({
id: file.id,
url: file.url,
bytes: downloaded.byteLength,
ok: true,
})
}

