I uploaded files less than 100MB & it took 1-2 minutes, now I'm trying to upload huge files, like more than 1GB. I tried this way but after 4-5 minutes it give me an error (Like: Fail to fetch....)
Is there any way to upload it? Please help!
Uploading approach
const multer = Multer({
storage: Multer.memoryStorage(),
});
app.post("/api/upload/", multer.single("file"),
async function (req, res, next) {
try {
if (!req.file) {
res.status(400).json({
success: false,
message: "File is not sent",
});
return;
}
// Create a new blob in the bucket and upload the file data.
const blob = bucket.file(req.file.originalname);
const blobStream = blob.createWriteStream({
// metadata: {
// contentType: "video/mp4",
// },
gzip: true,
resumable: true,
});
blobStream.on("error", (err) => {
console.log(err.message);
console.log(err.name);
next(err);
});
blobStream.on("finish", async () => {
// The public URL can access the file via HTTP directly.
const publicUrl = format(
`https://storage.googleapis.com/${bucket.name}/${blob.name}`
);
res.status(201).json({
success: true,
message: "Upload success",
});
});
blobStream.end(req.file.buffer);
} catch (error: any) {
return ThrowError(error);
}
}
);
app.use(express.json({ limit: "5000mb" }));
app.use(express.urlencoded({ extended: true, limit: "5000mb" }));