Exemple #1
0
  def read_file(self, filename):
    self.response.write('Truncated file content:\n')

    gcs_file = gcs.open(filename)
    self.response.write(gcs_file.readline())
    gcs_file.seek(-1024, os.SEEK_END)
    self.response.write(gcs_file.read())
    gcs_file.close()
Exemple #2
0
 def create_file(self, filename):
   self.response.write('Creating file %s\n' % filename)
   write_retry_params = gcs.RetryParams(backoff_factor=1.1)
   gcs_file = gcs.open(filename, 'w', content_type='text/plain', options={'x-goog-acl': 'public-read-write'}, retry_params=write_retry_params)
   gcs_file.write('abcde\n')
   gcs_file.write('f'*1024 + '\n')
   gcs_file.close()
   self.tmp_filenames_to_clean_up.append(filename)
Exemple #3
0
    def post(self):
        self.response.headers["x-goog-project-id"] = "530140140149"
        self.response.headers["x-goog-acl"] = 'public-read-write'
        cloudstorage.RetryParams(
                                initial_delay=0.2,
                                max_delay=5.0,
                                backoff_factor=2,
                                max_retry_period=15
                            )
        # file_to_write = self.request.get("file")
        filename = "/geak-trash/somefile.jpg"
        with cloudstorage.open(filename, 'w', content_type='image/jpeg', options={'x-goog-acl': 'public-read-write'}) as gcsfile:
            gcsfile.write(self.request.get("file"))
            gcsfile.close()

        ofile = cloudstorage.open(filename)
        self.response.headers["Content-Type"] = "image/jpeg"
        self.response.out.write(dir(ofile))
        self.response.out.write(ofile)
        ofile.close()