Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reset the last PR #133

Merged
merged 1 commit into from
Jul 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/fog/aliyun/models/storage/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,12 @@ def save(options = {})
end
if body.is_a?(::File)
service.put_object(object, body, options.merge(bucket: bucket_name))
data = service.head_object(object, bucket: bucket_name)
elsif body.is_a?(String)
service.put_object_with_body(object, body, options.merge(bucket: bucket_name))
data = service.put_object_with_body(object, body, options.merge(bucket: bucket_name)).data
else
raise Fog::Aliyun::Storage::Error, " Forbidden: Invalid body type: #{body.class}!"
end
data = service.head_object(object, bucket: bucket_name)
update_attributes_from(data)
refresh_metadata

Expand Down Expand Up @@ -199,7 +199,7 @@ def metadata_prefix
end

def update_attributes_from(data)
merge_attributes(data.headers.reject { |key, _value| ['Content-Length', 'Content-Type'].include?(key) })
merge_attributes(data[:headers].reject { |key, _value| ['Content-Length', 'Content-Type'].include?(key) })
end
end
end
Expand Down
11 changes: 9 additions & 2 deletions lib/fog/aliyun/requests/storage/head_object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,15 @@ class Real
def head_object(object, options = {})
bucket_name = options[:bucket]
bucket_name ||= @aliyun_oss_bucket
# Using OSS ruby SDK to fix performance issue
@oss_http.head({:bucket => bucket_name, :object => object}, {})
resource = bucket_name + '/' + object
ret = request(
expects: [200, 404],
method: 'HEAD',
path: object,
bucket: bucket_name,
resource: resource
)
ret
end
end
end
Expand Down
12 changes: 10 additions & 2 deletions lib/fog/aliyun/requests/storage/put_object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,16 @@ def put_object(object, file = nil, options = {})
def put_object_with_body(object, body, options = {})
bucket_name = options[:bucket]
bucket_name ||= @aliyun_oss_bucket
# Using OSS ruby SDK to fix performance issue
@oss_http.put({:bucket => bucket_name, :object => object}, {:body => body})

resource = bucket_name + '/' + object
request(
expects: [200, 203],
method: 'PUT',
path: object,
bucket: bucket_name,
resource: resource,
body: body
)
end

def put_folder(bucket, folder)
Expand Down