Closed
Labels
api: storageIssues related to the Cloud Storage API.Issues related to the Cloud Storage API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.‘Nice-to-have’ improvement, new feature or different behavior or design.type: questionRequest for information or clarification. Not an issue.Request for information or clarification. Not an issue.
Description
I expected the following call to rename an object. Unfortunately, its behaviour is not the expected, and it's very different from other similar calls like setMetadata().
Storage gcs = ...;
gcs.update(BlobInfo.newBuilder("existingBucket", "existingObject")
.setBlobId(BlobId.of("existingBucket", "newObject"))
.build());
AFAICT, this tries to make a dummy update to gs://existingBucket/newObject, which fails because the URI doesn't exist.
Logically, the behaviour of this call should be to rename the object, which is what I want to do, and appears to be impossible as per this: gsutil mv copies and removes, which ideally we would avoid doing.
Is there any way to rename a file that doesn't involve copying and removing?
If not, then I'd like to request one.
Metadata
Metadata
Assignees
Labels
api: storageIssues related to the Cloud Storage API.Issues related to the Cloud Storage API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.‘Nice-to-have’ improvement, new feature or different behavior or design.type: questionRequest for information or clarification. Not an issue.Request for information or clarification. Not an issue.
Activity
yihanzhen commentedon Dec 1, 2017
@joaoandremartins Please refer to this code snippet from the
Storageinterface to update metadata of a blob:Feel free to repost if that does not solve your problem.
joaoandremartins commentedon Dec 1, 2017
@hzyi-google thanks for the help.
Unfortunately, that didn't work. I'm still getting a
Not founderror.As I mentioned in my report,
setBlobId()isn't having the desired effect. This should be looked into.yihanzhen commentedon Dec 1, 2017
@joaoandremartins Thanks for the feedback. I'll take a further look.
yihanzhen commentedon Dec 1, 2017
It seems that Object#update is only used to update the metadata per here. Therefore additional changes have to be made outside the client library for this request. Can you tell a look as well @neozwu ?
pongad commentedon Jan 22, 2018
IIUC, Storage objects cannot be "renamed". To rename, you must copy to the new place and delete the original. This doc provides some code samples.
joaoandremartins commentedon Jan 22, 2018
I understand that renaming is currently impossible.
This issue is a feature request to have it implemented eventually -- why are you closing it?
yihanzhen commentedon Jan 22, 2018
@joaoandremartins I marked this issue as a feature request and added it to the backlog (Though I believe there is a chance that GCS does not allow renaming objects by design). Comments and discussion are still welcome here.
joaoandremartins commentedon Jan 22, 2018
Thanks a lot for the explanation @hzyi-google
If it's impossible to rename things by design in GCS, then feel free to do however you like with this issue. Having to pay for operations just to rename an object doesn't feel right, though.
pongad commentedon Jan 23, 2018
@joaoandremartins I'm sorry I didn't communicate clearly. The Storage API itself provides no way to rename objects. @hzyi-google Thank you for adding this to feature backlog.
feat: Add missing storage related fields to Table, TableInfo and Stan…
deps: update google api dependencies (#2672)
chore(main): release 2.41.0 (#2820)
chore: Update generation configuration at Sun Aug 18 02:16:53 UTC 2024 (
feat: Enable Subscriber StreamingPull keepalives by increasing the St…
feat: Enable Subscriber StreamingPull keepalives by increasing the St…
fix: Add missing break; to PROTO and ENUM value type check (googleapi…
chore(main): release 2.67.0 (googleapis#2678)