-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #306 from nolith/delete_object_url
Expose Storage pre-signed object delete url
- Loading branch information
Showing
4 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
module Fog | ||
module Storage | ||
class GoogleJSON | ||
class Real | ||
# Get an expiring object url from Google Storage for deleting an object | ||
# https://cloud.google.com/storage/docs/access-control#Signed-URLs | ||
# | ||
# @param bucket_name [String] Name of bucket containing object | ||
# @param object_name [String] Name of object to get expiring url for | ||
# @param expires [Time] Expiry time for this URL | ||
# | ||
# @return [String] Expiring object https URL | ||
def delete_object_url(bucket_name, object_name, expires) | ||
raise ArgumentError.new("bucket_name is required") unless bucket_name | ||
raise ArgumentError.new("object_name is required") unless object_name | ||
https_url({ | ||
:headers => {}, | ||
:host => @host, | ||
:method => "DELETE", | ||
:path => "#{bucket_name}/#{object_name}" | ||
}, expires) | ||
end | ||
end | ||
|
||
class Mock | ||
def delete_object_url(bucket_name, object_name, expires) | ||
raise ArgumentError.new("bucket_name is required") unless bucket_name | ||
raise ArgumentError.new("object_name is required") unless object_name | ||
https_url({ | ||
:headers => {}, | ||
:host => @host, | ||
:method => "DELETE", | ||
:path => "#{bucket_name}/#{object_name}" | ||
}, expires) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
module Fog | ||
module Storage | ||
class GoogleXML | ||
class Real | ||
# Get an expiring object url from Google Storage for deleting an object | ||
# | ||
# ==== Parameters | ||
# * bucket_name<~String> - Name of bucket containing object | ||
# * object_name<~String> - Name of object to get expiring url for | ||
# * expires<~Time> - An expiry time for this url | ||
# | ||
# ==== Returns | ||
# * response<~Excon::Response>: | ||
# * body<~String> - url for object | ||
# | ||
def delete_object_url(bucket_name, object_name, expires) | ||
raise ArgumentError.new("bucket_name is required") unless bucket_name | ||
raise ArgumentError.new("object_name is required") unless object_name | ||
https_url({ | ||
:headers => {}, | ||
:host => @host, | ||
:method => "DELETE", | ||
:path => "#{bucket_name}/#{object_name}" | ||
}, expires) | ||
end | ||
end | ||
|
||
class Mock | ||
def delete_object_url(bucket_name, object_name, expires) | ||
raise ArgumentError.new("bucket_name is required") unless bucket_name | ||
raise ArgumentError.new("object_name is required") unless object_name | ||
https_url({ | ||
:headers => {}, | ||
:host => @host, | ||
:method => "DELETE", | ||
:path => "#{bucket_name}/#{object_name}" | ||
}, expires) | ||
end | ||
end | ||
end | ||
end | ||
end |