1

I've came across a very strange issue with firebase storage. One of our users manages to create files ending with slash:

file ending with slash:

He claims that he uses only web console, etc and doesn't do anything special. If I try to copy such file using gsutil I (obviously) get the following error:

Copying images/20610/... Skipping attempt to download to filename ending with slash (images/20610/). This typically happens when using gsutil to download from a subdirectory created by the Cloud Console (https://cloud.google.com/console)

Extended attributes do not show anything unusual except that this is indeed a file with a slash at the and in its filename:

    Creation time:          Mon, 27 Apr 2020 16:32:12 GMT
    Update time:            Mon, 27 Apr 2020 16:32:12 GMT
    Storage class:          STANDARD
    Content-Length:         11
    Content-Type:           text/plain
    Hash (crc32c):          XkI+Dw==
    Hash (md5):             apnFdauH+MfR7R5S5+NJzg==
    ETag:                   CL7wy46EiekCEAE=
    Generation:             1588005132499006
    Metageneration:         1

My question basically is - how is it possible? and what to do to prevent this?

thanks in advance!

PrimeSeventyThree
  • 940
  • 2
  • 9
  • 24
  • Just implement a check to see if its an image, and furthermore, check the file type. https://stackoverflow.com/questions/889333/how-to-check-if-a-file-is-a-valid-image-file this might hep – Harry J Apr 28 '20 at 01:53

1 Answers1

0

You'll get an object with a trailing slash in the name if you create a folder using the Cloud Console.

Mike Schwartz
  • 11,511
  • 1
  • 33
  • 36
  • well, If you look at the screenshot closely - that object is not a folder, but a file with a slash in it's name. – PrimeSeventyThree Apr 28 '20 at 17:14
  • Sorry, I missed that before. GCS doesn't have restrictions on whether object names end with a "/"; it's a client choice whether to permit that, and how to interpret objects named that way. gsutil and the Cloud Console (which are clients) won't allow creating objects that end with "/". Are you certain your user didn't use some other client to create the object? – Mike Schwartz Apr 28 '20 at 18:37
  • I can't be a 100% positive, but I've asked directly a few times and the user confirmed that he uses only standard web based cloud console... – PrimeSeventyThree Apr 28 '20 at 20:02