I want to upload the file using the Automatic Parallel Composite Uploads of gsutil to Cloud Storage from Google App Engine. That I want you to tell me there are two. The contents of the above whether it is possible. If possible, it is insufficient contents in the following sources.
#!/usr/bin/python2.7
# -*- coding: utf-8 -*-
import logging
import webapp2
import time
from google.appengine.ext import db
import boto
GOOGLE_STORAGE = 'gs'
LOCAL_FILE = 'file'
TEST_BUCKET = 'test'
class UploadHandler(webapp2.RequestHandler):
def post(self):
config = boto.config
config.add_section('Credentials')
config.add_section('GSUtil')
config.set('Credentials', 'gs_access_key_id', 'XXXXX')
config.set('Credentials', 'gs_secret_access_key','XXXXX')
config.set('GSUtil', 'parallel_composite_upload_threshold', '9M')
config.set('GSUtil', 'parallel_composite_upload_component_size', '3M')
text = self.request.get('file')
uri = boto.storage_uri(TEST_BUCKET, GOOGLE_STORAGE)
try:
header_values = {"x-goog-api-version": "2","x-goog-project-id": "XXXXX"}
uri.create_bucket(headers=header_values)
print 'Successfully created bucket "%s"' % 'TEST_BUCKET'
exce`enter code here`pt boto.exception.StorageCopyError, e:
print 'Failed to create bucket:',e
filename = 'test.txt'
dst_uri = boto.storage_uri(TEST_BUCKET + '/' + filename, GOOGLE_STORAGE)
dst_uri.new_key().set_contents_from_string(text)