示例#1
0
    def write(self, filename, content, content_type):
        """
        TODO: Check if filename has leading slash.
        """
        
        # Prep the filename
        filename = "/%s/%s" % (self.bucket, filename)

        write_retry_params = gcs.RetryParams(backoff_factor=1.1)

        gcs_file = gcs.open(filename,
                            'w',
                            content_type=content_type,
                            options={'x-goog-acl': 'public-read',
                                     'x-goog-meta-bar': 'bar'},
                            retry_params=write_retry_params)
        gcs_file.write(content)
        gcs_file.close()

        return filename
示例#2
0
    def read(self, filename):
        """
        """
        gcs_file = gcs.open(filename)

        return gcs_file.read()