Ivan
Ivan
Explore posts from servers
CDCloudflare Developers
Created by Ivan on 4/30/2023 in #r2
Hi all am currently trying to perform a
On the front end, I am splicing files using a simple .splice function.
export const createChunks = (
file: File,
chunkSize = 15 * 1024 * 1024 /* cSize should be byte 1024*1 = 1KB */
) => {
let offset = 0;
const originalFileExtension = getFileExtension(file);
console.log(`Identified Extension as ${originalFileExtension}`);
const chunks = [];
while (offset < file.size) {
const chunkEnd = Math.min(file.size, offset + chunkSize);
const truncatedBlob = file.slice(offset, chunkEnd);
const truncatedFile = new File(
[truncatedBlob],
`audio-${offset}-${chunkEnd}.${originalFileExtension}`,
{
type: file.type,
}
);
chunks.push(truncatedFile);
offset += chunkSize;
}
return chunks;
};
export const createChunks = (
file: File,
chunkSize = 15 * 1024 * 1024 /* cSize should be byte 1024*1 = 1KB */
) => {
let offset = 0;
const originalFileExtension = getFileExtension(file);
console.log(`Identified Extension as ${originalFileExtension}`);
const chunks = [];
while (offset < file.size) {
const chunkEnd = Math.min(file.size, offset + chunkSize);
const truncatedBlob = file.slice(offset, chunkEnd);
const truncatedFile = new File(
[truncatedBlob],
`audio-${offset}-${chunkEnd}.${originalFileExtension}`,
{
type: file.type,
}
);
chunks.push(truncatedFile);
offset += chunkSize;
}
return chunks;
};
2 replies
CDCloudflare Developers
Created by Ivan on 4/30/2023 in #r2
Hi all am currently trying to perform a
I tried putting my source code together here in case anyone wants to give it a spin Workers : https://gist.github.com/ivanleomk/d31d49ce7412dc958bec353a273e0925
2 replies
CDCloudflare Developers
Created by Ivan on 4/29/2023 in #workers-help
Unable to perform multi-part upload for files
Thanks so much @kiannh 🙂
14 replies
CDCloudflare Developers
Created by Ivan on 4/29/2023 in #workers-help
Unable to perform multi-part upload for files
Hmm, ok nvm I will try working with the s3 api first and see if that works out
14 replies
CDCloudflare Developers
Created by Ivan on 4/29/2023 in #workers-help
Unable to perform multi-part upload for files
14 replies
CDCloudflare Developers
Created by Ivan on 4/29/2023 in #workers-help
Unable to perform multi-part upload for files
File gets broken up into 13 5.24 mb chunks and 1.01 mb chunk.
14 replies
CDCloudflare Developers
Created by Ivan on 4/29/2023 in #workers-help
Unable to perform multi-part upload for files
But i'm getting the same error on my local wrangler server and my deployed worker
14 replies
CDCloudflare Developers
Created by Ivan on 4/29/2023 in #workers-help
Unable to perform multi-part upload for files
Have been using the same file to test
14 replies
CDCloudflare Developers
Created by Ivan on 4/29/2023 in #workers-help
Unable to perform multi-part upload for files
It's around 60mb
14 replies
CDCloudflare Developers
Created by Ivan on 4/29/2023 in #workers-help
Unable to perform multi-part upload for files
I'm using the same worker provided in the docs too haha
14 replies
CDCloudflare Developers
Created by Ivan on 4/29/2023 in #workers-help
Unable to perform multi-part upload for files
So I reverted back to the original algorithm I used
xport const createChunks = (
file: File,
chunkSize = 15 * 1024 * 1024 /* cSize should be byte 1024*1 = 1KB */
) => {
let offset = 0;
const originalFileExtension = getFileExtension(file);
console.log(`Identified Extension as ${originalFileExtension}`);
const chunks = [];
while (offset < file.size) {
const chunkEnd = Math.min(file.size, offset + chunkSize);
const truncatedBlob = file.slice(offset, chunkEnd);
const truncatedFile = new File(
[truncatedBlob],
`audio-${offset}-${chunkEnd}.${originalFileExtension}`,
{
type: file.type,
}
);
chunks.push(truncatedFile);
offset += chunkSize;
}
return chunks;
};
xport const createChunks = (
file: File,
chunkSize = 15 * 1024 * 1024 /* cSize should be byte 1024*1 = 1KB */
) => {
let offset = 0;
const originalFileExtension = getFileExtension(file);
console.log(`Identified Extension as ${originalFileExtension}`);
const chunks = [];
while (offset < file.size) {
const chunkEnd = Math.min(file.size, offset + chunkSize);
const truncatedBlob = file.slice(offset, chunkEnd);
const truncatedFile = new File(
[truncatedBlob],
`audio-${offset}-${chunkEnd}.${originalFileExtension}`,
{
type: file.type,
}
);
chunks.push(truncatedFile);
offset += chunkSize;
}
return chunks;
};
But it still throws the same error that
Error: completeMultipartUpload: Your proposed upload is smaller than the minimum allowed object size. (10011)
at async Object.fetch (index.js:52:31) {
stack: Error: completeMultipartUpload: Your proposed uplo…10011)
at async Object.fetch (index.js:52:31),
message: completeMultipartUpload: Your proposed upload is s…ler than the minimum allowed object size. (10011)
}
Error: completeMultipartUpload: Your proposed upload is smaller than the minimum allowed object size. (10011)
at async Object.fetch (index.js:52:31) {
stack: Error: completeMultipartUpload: Your proposed uplo…10011)
at async Object.fetch (index.js:52:31),
message: completeMultipartUpload: Your proposed upload is s…ler than the minimum allowed object size. (10011)
}
14 replies
CDCloudflare Developers
Created by Ivan on 4/29/2023 in #workers-help
Unable to perform multi-part upload for files
For context, the object I am testing this on is ~60mb. I generated chunks manually using the .slice function on the File object using the following code
export const createChunks = (
file: File,
chunkSize = 15 * 1024 * 1024 /* cSize should be byte 1024*1 = 1KB */
) => {
let offset = 0;
const originalFileExtension = getFileExtension(file);
console.log(`Identified Extension as ${originalFileExtension}`);
const chunks = [];
while (offset < file.size) {
const chunkEnd = Math.min(file.size, offset + chunkSize);
const truncatedBlob = file.slice(offset, chunkEnd);
const truncatedFile = new File(
[truncatedBlob],
`audio-${offset}-${chunkEnd}.${originalFileExtension}`,
{
type: file.type,
}
);
chunks.push(truncatedFile);
offset += chunkSize;
}
return chunks;
};
export const createChunks = (
file: File,
chunkSize = 15 * 1024 * 1024 /* cSize should be byte 1024*1 = 1KB */
) => {
let offset = 0;
const originalFileExtension = getFileExtension(file);
console.log(`Identified Extension as ${originalFileExtension}`);
const chunks = [];
while (offset < file.size) {
const chunkEnd = Math.min(file.size, offset + chunkSize);
const truncatedBlob = file.slice(offset, chunkEnd);
const truncatedFile = new File(
[truncatedBlob],
`audio-${offset}-${chunkEnd}.${originalFileExtension}`,
{
type: file.type,
}
);
chunks.push(truncatedFile);
offset += chunkSize;
}
return chunks;
};
This yields around 13 chunks which each are 5242880 bytes in size and a last one which is 101232 in size.
14 replies