【发布时间】:2016-08-29 19:39:54
【问题描述】:
我的批量删除代码如下:
@staticmethod
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))
所以,当我删除多个对象时,它只会删除一个带有拉丁字符和文件的文件,它们的名称中没有空格。但是,网站上的文件也会消失,但不会从谷歌云存储中消失。
伙计们,你能帮我升级这个代码吗? :3
【问题讨论】:
标签: python google-app-engine google-cloud-storage fileserver