GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — storage: Support for folders · Issue #337 · googleapis/google-cloud-node

storage: Support for folders #337

New issue
Copy link
New issue
Copy link
Closed
Closed
storage: Support for folders#337
Copy link
Assignees
stephenplusplus
Labels
🚨This issue needs some love.api: storageIssues related to the Cloud Storage API.triage meI really want to be triaged.
Milestone
Storage Stable

Description

@pierre-b
pierre-b
opened on Dec 22, 2014
Issue body actions

Hi,

Is it possible to upload a file into a folder ?

Thanks

Activity

Next
  1. cristiano-belloni commented on Dec 22, 2014

    @cristiano-belloni
    cristiano-belloni
    on Dec 22, 2014
    Contributor
    More actions

    Hi @pierre-b,
    what happens if you do yourBucket.file('myFolderName/myFileName')? It should just work.

  2. pierre-b commented on Dec 22, 2014

    @pierre-b
    pierre-b
    on Dec 22, 2014
    Author
    More actions

    Yes @janesconference it works with the createWriteStream function, but not with the bucket.upload one:

    bucket.upload(sourcePath, options, function(error, file) {
    });
  3. cristiano-belloni commented on Dec 22, 2014

    @cristiano-belloni
    cristiano-belloni
    on Dec 22, 2014
    Contributor
    More actions

    Never tried it, so take it with a grain of salt, but you can try:

    bucket.upload(encodeURIComponent('myFolderName/myFileName'), options, function(error, file) { });

  4. pierre-b commented on Dec 22, 2014

    @pierre-b
    pierre-b
    on Dec 22, 2014
    Author
    More actions

    I think it should be added to the upload() by default, like in S3.

  5. ryanseys commented on Dec 22, 2014

    @ryanseys
    ryanseys
    on Dec 22, 2014
    Contributor
    More actions

    I agree. Did you try that and it worked?

  6. stephenplusplus commented on Dec 22, 2014

    @stephenplusplus
    stephenplusplus
    on Dec 22, 2014
    Contributor
    More actions

    @pierre-b can you paste the code you used to upload the file, as well as what version of gcloud you're using?

  7. stephenplusplus commented on Dec 22, 2014

    @stephenplusplus
    stephenplusplus
    on Dec 22, 2014
    Contributor
    More actions

    To elaborate more, upload can be called a few different ways, but the most simple is probably:

    myBucket.upload("/Users/stephen/Desktop/photo.jpg", function (err, file) {})

    In this case, I didn't specify anything about the destination file, only that I want one to be created based on the file at "/Users/stephen/Desktop/photo.jpg". The upload method will detect the file name as being "photo.jpg", and will drop it in your bucket with the same name and the contents at the given file path.

    upload doesn't treat your local file system's hierarchy as being identical to your bucket's hierarchy, so it needs to be told explicitly where you wish the file to end up:

    myBucket.upload("/Users/stephen/Desktop/photo.jpg", {
      destination: myBucket.file("my-photos/photo.jpg")
    }, function (err, file) {})

    Now the file should end up inside a directory called "my-photos", named "photo.jpg". If you were using it this way, and it's not working, that's a bug we need to squash.

    Reacted by Jaskeerat Singh Randhawa
    Reacted by Ulises Manuel Vargas De Sousa
  8. stephenplusplus
    changed the title [-]Support for folders[/-] [+]storage: Support for folders[/+] on Dec 22, 2014
  9. ryanseys commented on Dec 23, 2014

    @ryanseys
    ryanseys
    on Dec 23, 2014
    Contributor
    More actions

    Can confirm that using the destination option and providing a file object like suggested above will correctly upload the file into a folder. @pierre-b Can you confirm this also works for you?

  10. pierre-b commented on Dec 24, 2014

    @pierre-b
    pierre-b
    on Dec 24, 2014
    Author
    More actions

    Using v0.11.0 the following doesn't work too, the file is not saved in the folder:

    myBucket.upload("/Users/stephen/Desktop/photo.jpg", {
      destination: myBucket.file("my-photos/photo.jpg")
    }, function (err, file) {})
  11. cristiano-belloni commented on Dec 24, 2014

    @cristiano-belloni
    cristiano-belloni
    on Dec 24, 2014
    Contributor
    More actions

    This is working for me on v0.12.0,

    return resourceBucket.upload(
            local,
            {
                destination: remote,
                metadata: { contentType: contentType }
            }, function (err, file) {
                if (cb) {
                    cb(err, file);
                }
            });
    

    Where local is my local file name ( ie: '/mylocalpath/myfile' ) and remote is my remote file path ( ie: 'remotepath/myfile' ), both without any encoding.

  12. stephenplusplus commented on Jan 5, 2015

    @stephenplusplus
    stephenplusplus
    on Jan 5, 2015
    Contributor
    More actions

    Going to close as all signs point to this working. If you still can't get it working, feel free to re-open with more details. If you have ideas for how we can improve the documentation or API to make a better experience for others, those are always welcome as well.

  13. stephenplusplus
    closed this as completedon Jan 5, 2015
  14. jgeewax
    added
    api: storageIssues related to the Cloud Storage API.
    enhancement
    on Feb 2, 2015
  15. 34 remaining items

  16. sofisl
    added 2 commits that reference this issue on Feb 3, 2026

    build: check for 404s in the docs (#337)

    5dcc3eb

    chore: release 1.2.0 (#337)

    c39c17b
  17. sofisl
    added 2 commits that reference this issue on Feb 24, 2026

    make synth.py generate library to ./dev (#337)

    a323831

    semver: do not support upload() from url (#337)

    0e113a7
  18. GautamSharda
    added a commit that references this issue on Feb 25, 2026

    docs: update documentation for bigquerystorage v1beta1 (#337)

    890cbd3
  19. sofisl
    added a commit that references this issue on Feb 26, 2026

    Enable prefer-const in the eslint config (#337)

    3088738
  20. GautamSharda
    added a commit that references this issue on Mar 5, 2026

    chore: update license file (#337)

    639a74e
  21. sofisl
    added 2 commits that reference this issue on Mar 5, 2026

    chore: migrate code from googleapis/gcp-metadata (#53)

    fa9a454

    chore(deps): update dependency sinon to v10 (#337)

    2cbad7d
  22. codyoss
    added 2 commits that reference this issue on Mar 9, 2026

    chore: store nodejs build artifacts in placer (#337)

    be8f70c

    chore: store nodejs build artifacts in placer (#337)

    30eb5dd
  23. GautamSharda
    added 2 commits that reference this issue on Mar 11, 2026

    Release v0.21.1 (#337)

    e47af42

    fix: use request_ for service-object (#337)

    c9d7ed8
  24. thiyaguk09
    added a commit that references this issue on Mar 18, 2026

    semver: do not support upload() from url (googleapis#337)

    8e2df2b
  25. feywind
    added a commit that references this issue on Mar 27, 2026

    Release v0.21.1 (#337)

    d5029d3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @stephenplusplus
    stephenplusplus

Labels

🚨This issue needs some love.api: storageIssues related to the Cloud Storage API.triage meI really want to be triaged.

Type

No type

Projects

No projects

    Milestone

    • Storage Stable

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.