googleapis / nodejs-storage

Node.js client for Google Cloud Storage: unified object storage for developers and enterprises, from live data serving to data analytics/ML to data archiving.
https://cloud.google.com/storage/
Apache License 2.0
897 stars 369 forks source link

uploadManyFiles prefix option turns forward slash to backward slash on windows, turning folders into full string file name, is this intended? #2301

Closed asary-dev closed 11 months ago

asary-dev commented 11 months ago

Environment details

Steps to reproduce

        const files_to_upload = [
            "images/image001.png",
            "images/image002.jpg",
        ]

        await tsfm.uploadManyFiles(files_to_upload, {
            prefix:"user_id_1/files",
            passthroughOptions: {
                gzip: true,
            }
        })

the code above will upload the files with the prefix and path as it's entire file name:

in turn making the url show up as

expecting it to correctly create directory such as:

only happens on windows machine, suspecting path.join function on the uploadManyFiles, is this intended?

removing the prefix options correctly uploads it into a directory as expected:

ddelgrosso1 commented 11 months ago

Thanks for opening this issue @asary-dev. You are correct, it shouldn't be changing the slashes like that. I will take a closer look as to why this is happening in a windows environment.