コード例 #1
0
 def stream_write(self, path, fp):
     # Minimum size of upload part size on GS is 5MB
     buffer_size = 5 * 1024 * 1024
     if self.buffer_size > buffer_size:
         buffer_size = self.buffer_size
     path = self._init_path(path)
     key = self.makeKey(path)
     key.set_contents_from_string(fp.read())
コード例 #2
0
ファイル: gcs.py プロジェクト: GaretJax/docker-registry
 def stream_write(self, path, fp):
     # Minimum size of upload part size on GS is 5MB
     buffer_size = 5 * 1024 * 1024
     if self.buffer_size > buffer_size:
         buffer_size = self.buffer_size
     path = self._init_path(path)
     key = self.makeKey(path)
     key.set_contents_from_string(fp.read())
コード例 #3
0
def __attempt_upload(file_path, bucket_name, key_name, log):
    time.sleep(backoff)
    bucket = __get_bucket(bucket_name)
    if key_name in bucket:
        raise ValueError('found %s already uploaded in %s' %
                         (key_name, bucket_name))
    key = boto.gs.key.Key(bucket, key_name)
    try:
        if (file_path.endswith('txt')):
            # make sure can be loaded as ascii!!!
            with open(file_path) as infile:
                contents = infile.read()
                key.set_contents_from_string(
                    str(contents.encode('ascii', 'replace')))
        else:
            key.set_contents_from_filename(file_path)
    finally:
        key.close()
コード例 #4
0
 def put_content(self, path, content):
     path = self._init_path(path)
     key = self.makeKey(path)
     key.set_contents_from_string(content)
     return path
コード例 #5
0
ファイル: gcs.py プロジェクト: GaretJax/docker-registry
 def put_content(self, path, content):
     path = self._init_path(path)
     key = self.makeKey(path)
     key.set_contents_from_string(content)
     return path