lib/filestack/utils/utils.rb in filestack-2.3.0 vs lib/filestack/utils/utils.rb in filestack-2.4.0
- old
+ new
@@ -71,11 +71,11 @@
# policy/signature
# @param [Hash] options User-defined options for
# multipart uploads
# @param [String] storage Storage destination
# (s3, rackspace, etc)
- # @return [Typhoeus::Response]
+ # @return [Hash]
def send_upload(apikey, filepath: nil, external_url: nil, security: nil, options: nil, storage: 'S3')
data = if filepath
{ fileUpload: File.open(filepath) }
else
{ url: external_url }
@@ -91,11 +91,12 @@
base = "#{base}&signature=#{signature}&policy=#{policy}"
end
response = make_call(base, 'post', parameters: data)
if response.code == 200
- handle = response.body['url'].split('/').last
+ response_body = JSON.parse(response.body)
+ handle = response_body['url'].split('/').last
return { 'handle' => handle }
end
raise response.body
end
@@ -388,10 +389,10 @@
end
rescue
raise 'BACKEND_NETWORK'
end
- fs_response = fs_response.body
+ fs_response = JSON.parse(fs_response.body)
# PUT to S3
begin
amazon_response = Typhoeus.put(
fs_response['url'], headers: fs_response['headers'], body: chunk