Apify Discord Mirror

Updated 5 months ago

File size upload to KeyValueStore

At a glance

The community member created an actor that downloads and uploads videos to a KeyValueStore, but encountered an error when uploading large videos due to the 2GB file size limit. A community member suggested using streams to avoid this issue, providing an example code snippet using the got and stream libraries to download and upload the videos using a streaming approach.

I created actor which downloads and uploads videos to KeyValueStore, some of videos are pretty big and getting this error:

2024-05-18T15:54:15.572Z Failed to upload video: RangeError [ERR_FS_FILE_TOO_LARGE]: File size (2183982088) is greater than 2 GiB

so anyway to get around this and what are best practices on apify for downloading and uploading of big files
o
1 comment
Hi, 2GB is the node's limit for reading files. You can avoid it by using streams:
Plain Text
import got from 'got'
import stream from 'node:stream'

const headers = { 'Content-Type': contentType }
await streamPipeline(
    got.stream.get(DOWNLOAD_URL, { headers }),
    new stream.PassThrough(),
    got.stream.put(UPLOAD_URL, { headers }),
)
Add a reply
Sign up and join the conversation on Discord