Skip to content
This repository has been archived by the owner on Feb 18, 2019. It is now read-only.

Commit

Permalink
Merge pull request #2 from juneboy86/feature/chenjun-add-msfetch-url-api
Browse files Browse the repository at this point in the history
Feature/chenjun add msfetch url api
  • Loading branch information
kayaklee authored Aug 26, 2016
2 parents 3867ffb + c9fcb79 commit 6863ec8
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/mss/core/signers/s3.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class S3
acl location logging notification partNumber policy
requestPayment torrent uploadId uploads versionId
versioning versions restore delete lifecycle tagging cors
website
website msfetch msfetchurl
)

QUERY_PARAMS = %w(
Expand Down
15 changes: 15 additions & 0 deletions lib/mss/s3/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,12 @@ def require_upload_id!(upload_id)
end
end

def require_msfetch_url!(msfetchurl)
validate!("msfetchurl", msfetchurl) do
"must not be blank" if msfetchurl.to_s.empty?
end
end

def require_part_number! part_number
validate!("part_number", part_number) do
"must not be blank" if part_number.to_s.empty?
Expand Down Expand Up @@ -1930,6 +1936,15 @@ def self.object_method(method_name, verb, *args, &block)

end

object_method(:msfetch_url, :get) do
configure_request do |req, options|
require_msfetch_url!(options[:msfetchurl])
req.add_param('msfetch')
super(req, options)
req.add_param('msfetchurl', options[:msfetchurl])
end
end

# Copies an object from one key to another.
# @overload copy_object(options = {})
# @param [Hash] options
Expand Down
10 changes: 10 additions & 0 deletions lib/mss/s3/s3_object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,16 @@ def delete options = {}

end


def fetch options = {}
client.msfetch_url(options.merge(
:bucket_name => bucket.name,
:key => key))

nil

end

# Restores a temporary copy of an archived object from the
# Glacier storage tier. After the specified `days`, Amazon
# S3 deletes the temporary copy. Note that the object
Expand Down

0 comments on commit 6863ec8

Please sign in to comment.