question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Rename storage objects returns 404 Not Found

See original GitHub issue

Hi. This feature over here for renaming GCS Objects is not working for me. Is this still active? I keep getting 404 Not found whereas I verified all my resources are present and I’m using correct paths and credentials.

Also, found mistake in documentation - you are using a different variable name in comments guide here and different in actual code over here.

Environment details

  • Node.js version: v14
  • npm version: v6
  • @google-cloud/storage version: ^5.8.5

Steps to reproduce

  1. I used this template - here. I’m trying to rename an existing file in same bucket.

Thanks!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:16 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
stephenpluspluscommented, May 10, 2021

Woo! Glad we got it figured out. Sorry for the confusion!

1reaction
stephenpluspluscommented, May 10, 2021

Thank you for taking the time to do that. The issue is how bucketName is defined. To get the folder name, pass that into the file() and move() methods. Could you try it with these changes?

//Import all files
async function rename(){
    //GCS Data Source
-   const bucketName = 'bucket-name/folder-name';   //folder-name is in format `TEST.FOLDER`
+   const bucketName = 'bucket-name';   //folder-name is in format `TEST.FOLDER`

// Import the Google Cloud client libraries
    const {Storage} = require('@google-cloud/storage');

// Instantiate BigQuery and Storage clients
    let projectId = require("../../credential-file.json").project_id;
    const storage = new Storage({
        keyFilename: "../../credential-file.json",
        projectId: projectId
    });

-   let destFileName = `test-2`;
+   let destFileName = `folder-name/test-2`;
-   await storage.bucket(bucketName).file('test-env-data-000000000000').move(destFileName);
+   await storage.bucket(bucketName).file('folder-name/test-env-data-000000000000').move(destFileName);
}

rename().catch(e => console.log(e));
Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to rename directory using Google Cloud SDK ...
I am trying to rename a directory of google cloud using the SDK. I am getting error message of 404 No such object:buketname/previousDirName...
Read more >
[External storage - Webdav] remote rename not detected
Steps to reproduce Make sure, you have a file/folder on your external webdav storage Configure that external webdav storage as a user (might ......
Read more >
Rename a File or Folder in an ObjectStore Share Using ...
The user does not have access to the share or the file/folder to be rename is not accessible inside the share. 404. Not...
Read more >
Usage details for "rename"
You can move a file to a new sub-directory while using the "rename" ... If the specified object does not exist, an HTTP...
Read more >
Path - Create - REST API (Azure Storage Services)
404 Not Found, RenameDestinationParentPathNotFound, "The parent directory of the destination path does not exist." 404 Not Found, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found