roopakv / google-photos

Library to make hitting the Google Photos api easy
MIT License
56 stars 22 forks source link

File size is greater than 2GB #40

Open Tobias-Secher opened 3 years ago

Tobias-Secher commented 3 years ago

I am trying to upload large files some 3gb+ but I keep getting this error. I'm using version 0.3.3 from npmjs.com

RangeError [ERR_FS_FILE_TOO_LARGE]: File size (3010883500) is greater than 2 GB
    at tryCreateBuffer (fs.js:343:13)
    at Object.readFileSync (fs.js:379:14)
    at Object.e.readFileSync (electron/js2c/asar_bundle.js:5:8583)
    at Transport.upload (C:\Users\tobia\Documents\workspace\photo-uploader\node_modules\googlephotos\lib\transport.js:32:18)
    at MediaItems.upload (C:\Users\tobia\Documents\workspace\photo-uploader\node_modules\googlephotos\lib\media_items\index.js:18:40)
    at uploadFiles (C:\Users\tobia\Documents\workspace\photo-uploader\main.js:121:49)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async getFilesFromDirectories (C:\Users\tobia\Documents\workspace\photo-uploader\main.js:94:9) {
  code: 'ERR_FS_FILE_TOO_LARGE'

My uplaod methos looks like this

const uploadFiles = async (files, albumName, prefix) => {
    try {
        // create album
        const prefixTitle = prefix ? `- ${prefix}` : '';
        const albumRes = await photos.albums.create(`${albumName} ${prefixTitle}`);
        console.log(albumRes)
        // Upload files
        for (const file of files) {
            const res = await photos.mediaItems.upload(albumRes.id, file.name, file.fullPath);
            console.log(res);
        }
        console.log(`UPLOAD FROM ${albumName} SUCCESSFULLY`)

    } catch (error) {
        console.log(error)
    }
}