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