mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[ninefold|storage] allow overwriting files for consistency
This commit is contained in:
parent
e41aab3cc2
commit
89f5a07c71
1 changed files with 7 additions and 5 deletions
|
@ -73,13 +73,15 @@ module Fog
|
|||
options[:headers] ||= {}
|
||||
options[:headers]['Content-Type'] = content_type if content_type
|
||||
options[:body] = body
|
||||
if objectid
|
||||
# pre-existing file, do a PUT
|
||||
data = connection.put_namespace(ns, options)
|
||||
else
|
||||
# new file, POST
|
||||
begin
|
||||
data = connection.post_namespace(ns, options)
|
||||
self.objectid = data.headers['location'].split('/')[-1]
|
||||
rescue => error
|
||||
if error.message =~ /The resource you are trying to create already exists./
|
||||
data = connection.put_namespace(ns, options)
|
||||
else
|
||||
raise error
|
||||
end
|
||||
end
|
||||
# merge_attributes(data.headers)
|
||||
true
|
||||
|
|
Loading…
Reference in a new issue