0

I want to delete the file contents from the file in gs bucket, just content, not the file, basically want a 0kb file.

Inside the shell script I tried cp /dev/null (basic Unix cmd) but got error saying "cannot recreate file "

Is there any gsutil command to delete the contents from cloud storage via shell script

Deb
  • 1
  • 1
  • 1
    Please edit the question to show exactly what you tried that doesn't work the way you expect. We should be able to reproduce the results that you observe using the complete instructions you provide. "It is not working" isn't really helpful. – Doug Stevenson Jun 19 '23 at 19:09
  • Error message was "cannot recreate the file in – Deb Jun 19 '23 at 19:14
  • Right, but you should also show the specific command you ran so that we can duplicate the same behavior for ourselves. We can't tell if you're doing something that should actually work. – Doug Stevenson Jun 19 '23 at 19:47
  • You can't edit objects in-place in GCS. In any case you may need to download the files, delete the content and then upload them again. You can check https://stackoverflow.com/a/58948667/12265927 – Puteri Jun 19 '23 at 20:37
  • A key item to remember is that Google Cloud Storage objects are immutable. The contents cannot be changed once uploaded. You can simply upload a zero-byte object to create a new version of the object. If object versioning is enabled, the original object version will still exist. – John Hanley Jun 19 '23 at 23:15

0 Answers0