Problem with russian file names and names with blank spaces on google cloud storage

44 views
Skip to first unread message

Никита Гуртовой

unread,
May 13, 2016, 8:36:31 AM5/13/16
to Google App Engine

Hello there!
I have some sad issue with rusian file names and names with blank spaces on google cloud storage. Sorry for posting this message here, but GCS haven't their own group.

My problem is:

When i store files in GCS with names, that contain blank spaces or russian character in their name, I can't delete them, using REST API.

My batch delete method is:

def gcs_batch_delete(gcs_file_names):
 logging
.debug('Deleting ' + str(len(gcs_file_names)) + ' files.')

 boundary
= '===============7330845974216740156=='
 headers
= {'Content-Type': 'multipart/mixed; boundary="' + boundary + '"'}
 data
= '--' + boundary + '\n'
 
template = """Content-Type: application/http

DELETE /storage/v1/b/%s/o/"""
% os.environ['GCS_BUCKET_NAME']
 bodies
= [template + urllib.quote_plus(filename) + '\n' for filename in gcs_file_names]
 data
+= ('\n--' + boundary + '\n').join(bodies)
 data
+= '\n--' + boundary + '\n'

 logging
.debug('Request:\n' + data)

 url
= 'https://www.googleapis.com/batch'
 result
= urlfetch.fetch(url=url, payload=data, method=urlfetch.POST, headers=headers)

 logging
.debug('urlfetch result: ' + str(result.content))
One moment here: I can't store files in GCS with names, that differ from original name.

So, i need to make a nice looking request to GCS to perform my batch delete. 
In this request file name must be exactly as it written to GCS.
Already asking this on overflow, but nothing helped. 

Hope, guys, u can help me to solve my problem :3


Christian F. Howes

unread,
May 16, 2016, 2:46:08 PM5/16/16
to Google App Engine
What is the response from the REST API when you attempt to delete?

have you tried the gcloud command line tool?  does it fail in the same way?

my only thought is encoding or escaping the special characters is the problem.  I am curious about the answer!

good luck,

cfh
Reply all
Reply to author
Forward
0 new messages