Skip to content

Commit

Permalink
Merge pull request #46 from HuseinA/master
Browse files Browse the repository at this point in the history
Fix Upload File in API
  • Loading branch information
efenfauzi authored May 4, 2020
2 parents b3c36e4 + 1d3bfdc commit 06fc833
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions obs/api/app/controllers/api/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 3 additions & 1 deletion obs/libs/bucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion tests/api/test_api_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 06fc833

Please sign in to comment.