You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"""
self.auth = oss2.Auth(OSS_ACCESS_KEY_ID, OSS_ACCESS_KEY_SECRET)
self.bucket = oss2.Bucket(self.auth, Endpoint, Bucket)
def upload_file(self, local_file_path, remote_file_path):
"""Upload a file to Aliyun OSS.
Args:
local_file_path (str): The path of the local file to upload.
remote_file_path (str): The path of the remote file to upload to.
Returns:
tuple: A tuple containing the URL of the uploaded file and a boolean indicating whether the upload was successful.
"""
try:
self.bucket.put_object_from_file(remote_file_path, local_file_path)
# * Default think the bucket is public read
return (
f"https://{self.bucket.bucket_name}.{self.bucket.endpoint.split('://')[1]}/{remote_file_path}",
True,
)
except Exception as e:
logging.error(f"Error to upload the file: {local_file_path}, {e}")
return e, False
此处也许不应该调用bucket.put_object_from_file
The text was updated successfully, but these errors were encountered:
情况
利用上传器工厂创建上传器
参数传入正确,AliOSS服务端配置正常(使用picgo-alioss时正常),但是Status-code 400
初步判断为
此处也许不应该调用bucket.put_object_from_file
The text was updated successfully, but these errors were encountered: