mirror of
https://github.com/logos-storage/logos-storage-js.git
synced 2026-01-02 21:43:10 +00:00
Send the file directly without splitting it into chunks in order to let the HTTP protocol handle the file itself.
This commit is contained in:
parent
f5dd224479
commit
834e5bd163
@ -1,19 +0,0 @@
|
||||
export const Chunks = {
|
||||
async split(file: File) {
|
||||
const totalSize = file.size;
|
||||
const chunkSize = 1024 * 1024 * 3; // 10MB
|
||||
|
||||
const chunks = [] as Uint8Array[];
|
||||
const amountOfChunks = Math.ceil(totalSize / chunkSize);
|
||||
|
||||
for (let index = 0; index < amountOfChunks; index++) {
|
||||
const start = index * chunkSize;
|
||||
const end = (index + 1) * chunkSize;
|
||||
|
||||
const chunk = await file.slice(start, end).arrayBuffer();
|
||||
chunks.push(new Uint8Array(chunk));
|
||||
}
|
||||
|
||||
return chunks;
|
||||
},
|
||||
};
|
||||
@ -1,5 +1,5 @@
|
||||
import { Api } from "../api/config";
|
||||
import { Chunks } from "../chunks/chunks";
|
||||
/*import { Chunks } from "../chunks/chunks";*/
|
||||
import { Fetch } from "../fetch-safe/fetch-safe";
|
||||
import type { SafeValue } from "../values/values";
|
||||
import type { CodexDataResponse, CodexNodeSpace } from "./types";
|
||||
@ -30,17 +30,17 @@ export class Data {
|
||||
return data;
|
||||
}
|
||||
|
||||
/* const mimetypes = [
|
||||
"image/png",
|
||||
"image/jpg",
|
||||
"image/jpeg",
|
||||
"audio/mp3",
|
||||
"video/mp4",
|
||||
"application/pdf",
|
||||
"application/msdoc",
|
||||
"text/plain",
|
||||
];
|
||||
*/
|
||||
/* const mimetypes = [
|
||||
"image/png",
|
||||
"image/jpg",
|
||||
"image/jpeg",
|
||||
"audio/mp3",
|
||||
"video/mp4",
|
||||
"application/pdf",
|
||||
"application/msdoc",
|
||||
"text/plain",
|
||||
];*/
|
||||
|
||||
return {
|
||||
error: false,
|
||||
data: {
|
||||
@ -102,9 +102,7 @@ export class Data {
|
||||
|
||||
xhr.open("POST", url, true);
|
||||
|
||||
await Chunks.split(file);
|
||||
|
||||
xhr.send(new Blob(await Chunks.split(file)));
|
||||
xhr.send(file);
|
||||
|
||||
xhr.onload = function () {
|
||||
if (xhr.status != 200) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user