コード例 #1
0
ファイル: s3_manager.py プロジェクト: hyahiaoui/SeleniumBase
 def upload_file(self, file_name, file_path):
     """ Upload a given file from the file_path to the bucket
         with the new name/path file_name. """
     upload_key = Key(bucket=self.bucket, name=file_name)
     content_type = "text/plain"
     if file_name.endswith(".html"):
         content_type = "text/html"
     elif file_name.endswith(".jpg"):
         content_type = "image/jpeg"
     elif file_name.endswith(".png"):
         content_type = "image/png"
     upload_key.set_contents_from_filename(file_path, headers={"Content-Type": content_type})
     upload_key.url = upload_key.generate_url(expires_in=3600).split("?")[0]
     try:
         upload_key.make_public()
     except Exception:
         pass
コード例 #2
0
ファイル: s3_manager.py プロジェクト: dougdragon/HotSalad
 def upload_file(self, file_name, file_path):
     """upload a given file from the file_path to the bucket
     with the new name/path file_name"""
     upload_key = Key(bucket=self.bucket, name=file_name)
     content_type = "text/plain"
     if file_name.endswith(".html"):
         content_type = "text/html"
     if file_name.endswith(".jpg"):
         content_type = "image/jpg"
     upload_key.set_contents_from_filename(file_path,
         headers={"Content-Type":content_type})
     upload_key.url = \
         upload_key.generate_url(expires_in=3600).split("?")[0]
     try:
         upload_key.make_public()
     except:
         pass # we get a http version error here, we're going to pass
     return file_name
コード例 #3
0
 def upload_file(self, file_name, file_path):
     """ Upload a given file from the file_path to the bucket
         with the new name/path file_name. """
     upload_key = Key(bucket=self.bucket, name=file_name)
     content_type = "text/plain"
     if file_name.endswith(".html"):
         content_type = "text/html"
     elif file_name.endswith(".jpg"):
         content_type = "image/jpeg"
     elif file_name.endswith(".png"):
         content_type = "image/png"
     upload_key.set_contents_from_filename(
         file_path,
         headers={"Content-Type": content_type})
     upload_key.url = \
         upload_key.generate_url(expires_in=3600).split("?")[0]
     try:
         upload_key.make_public()
     except Exception:
         pass