4

smart people. I working with firebase for my android app. And i need rename a folder specific in Storage. Somebody may please teach me how do it?

thanks for your time

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441

1 Answers1

5

The first thing you should know is that Cloud Storage doesn't really have "folders". Therefore, there is no operation to rename a folder.

You can think of Storage as a giant map of keys to values, where the keys are the names of the files (the full path), and the values are the content of the files. When the prefix for a path name overlaps with another path, it creates the appearance of a folder, which is helpful for organizing your data and navigating them in the console. But there are still no actual folders like you have in your computer's filesystem.

The closest thing to renaming a folder is actually just renaming each file whose path contains that "folder". So, if you have this file:

/foo/bar/file.jpg

and you want to rename "bar" to "baz", then you need to rename or somehow move the file to have this name instead:

/foo/baz/file.jpg

The operation is on the entire path of the file, not what appears to be a "folder" in the path. You will have to do this for each file whose name starts with "/foo/bar".

See also: Move/rename folder in Google Cloud Storage using nodejs gcloud api

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
  • Thanks for your quick response. It has become clear that there are no folders as such. Then could you please tell me how I can fit the route? considering that it is not only for a file but, for all those who share the same route. thanks. :D – Cristian Velasco Ramirez Jan 20 '20 at 18:58
  • This sounds like a new question to post. I've given options on how to rename a file. Anything more than that requires an explanation of what you're trying to do that's different. – Doug Stevenson Jan 20 '20 at 19:00
  • @DougStevenson how do I rename ? I can't find a rename method ? I'm working with flutter – Niteesh Jan 06 '21 at 17:55