user1848767
user1848767

Reputation: 53

How to delete a cloud-api uploaded image from my cloud console?

I am new to the Google Cloud API and am struggling with a couple of questions:

  1. I have successfully uploaded an image to my Google Cloud "bucket" using the sample project found at https://zatackcoder.com/upload-file-to-google-cloud-storage-using-php/ verbatim. No changes, except to put my own credentials in the source code. Upon success, Google returns the object details below:
kind    "storage#object"
id  "my_test_bucket/uploads/Europe-Map.png/5555226335851276"
selfLink    "https://www.googleapis.com/storage/v1/b/my_test_bucket/o/uploads%2FEurope-Map.png"
mediaLink   "https://www.googleapis.com/download/storage/v1/b/my_test_bucket/o/uploads%2FEurope-Map.png?generation=5555226335851276&alt=media"
name    "uploads/Europe-Map.png"
bucket  "my_test_bucket"
generation  "5555226335851276"
metageneration  "1"
contentType "image/png"
storageClass    "STANDARD"
size    "782467"
md5Hash "TPmaAjp5ub1jxIQChhOAsQ=="
crc32c  "PFU5yw=="
etag    "CAyMp/aioe8CEAE="
retentionExpirationTime "2120-03-09T11:58:35.882Z"
timeCreated "2021-03-08T17:58:35.882Z"
updated "2021-03-08T17:58:35.882Z"
timeStorageClassUpdated "2021-03-08T17:58:35.882Z"

I can see the new file from my Google Cloud console, but I cannot delete it from the console. When I try, I get the very helpful message: "Unable to delete file".

I imagine it has to do with ACU or other security but as owner of the bucket, from the cloud console itself, shouldn't I always be able to delete any and all files?

Upvotes: 1

Views: 151

Answers (1)

user1848767
user1848767

Reputation: 53

I found the problem - an error message appeared when I tried to delete it programmatically: "Object <...> is subject to bucket's retention policy and cannot be deleted, overwritten or archived until"

So I went into the bucket definition on my Google Cloud console and selected the "Retention" tab and was able to set retention to 1 second (it was set for 99 years which inhibited any kind of editing on the object for 99 years after uploading!)

Upvotes: 2

Related Questions