0

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)
Cœur
  • 37,241
  • 25
  • 195
  • 267
  • While gsutil makes use of the boto library, the boto library itself does not have any concept of gsutil, nor does the boto library provide support for parallel composite uploads. You could do this yourself by splitting the file into several pieces, uploading them concurrently, and then recombining them with a compose operation. – Brandon Yarbrough Dec 10 '13 at 18:07
  • Thank you, Mr.Brandon Yarbrough. I decided to shelve the implementation of this feature this time. Please tell me other solutions if you find. – Yusuke Fukui Dec 11 '13 at 05:26

0 Answers0