diff --git a/obs/api/app/controllers/api/storage.py b/obs/api/app/controllers/api/storage.py index b43b96b..0337645 100644 --- a/obs/api/app/controllers/api/storage.py +++ b/obs/api/app/controllers/api/storage.py @@ -316,6 +316,7 @@ def post(self, bucket_name): bucket_name=bucket_name, local_path=filename, object_name=object_name, + content_type=file.content_type, ) os.remove(filename) diff --git a/obs/libs/bucket.py b/obs/libs/bucket.py index dfa07d0..b360ade 100644 --- a/obs/libs/bucket.py +++ b/obs/libs/bucket.py @@ -123,7 +123,9 @@ def upload_object(**kwargs): resource = kwargs.get("resource") bucket_name = kwargs.get("bucket_name") - resource.Object(bucket_name, filename).upload_file(Filename=local_path) + resource.Object(bucket_name, filename).upload_file( + Filename=local_path, ExtraArgs={"ContentType": kwargs.get("content_type")} + ) def copy_object(resource, src_bucket, src_object_name, dest_bucket, dest_object_name): diff --git a/tests/api/test_api_storage.py b/tests/api/test_api_storage.py index 9546154..f78fbc6 100644 --- a/tests/api/test_api_storage.py +++ b/tests/api/test_api_storage.py @@ -19,7 +19,7 @@ def fake_resource(access_key, secret_key): "ResponseMetaData": {"RequestId": "e12"} } resouce.Object.return_value.download_file.side_effect = lambda: "" - resouce.Object.return_value.upload_file.side_effect = lambda Filename: "" + resouce.Object.return_value.upload_file.side_effect = lambda Filename, ExtraArgs: "" resouce.Object.return_value.copy.side_effect = lambda source: "" return resouce