Skip to content

Commit

Permalink
Merge 95e6f9c into 0a9b0e2
Browse files Browse the repository at this point in the history
  • Loading branch information
gabifija committed Oct 10, 2018
2 parents 0a9b0e2 + 95e6f9c commit cc54d68
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/filestack/models/filestack_transform.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def av_convert(options)
if response.code == 200
return AV.new(url, apikey: @apikey, security: @security)
end
response.body
JSON.parse(response.body)
end

# Add debug parameter to get information on transformation image
Expand Down
6 changes: 4 additions & 2 deletions lib/filestack/utils/multipart_upload_utils.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'base64'
require 'timeout'
require 'digest'
require 'mimemagic'
require 'json'
Expand Down Expand Up @@ -57,7 +58,7 @@ def multipart_start(apikey, filename, filesize, mimetype, security, options)
headers: FilestackConfig::HEADERS
)
if response.code == 200
response.body
JSON.parse(response.body)
else
raise RuntimeError.new(response.body)
end
Expand Down Expand Up @@ -144,6 +145,7 @@ def upload_chunk(job, apikey, filepath, options)
FilestackConfig::MULTIPART_UPLOAD_URL, body: data,
headers: FilestackConfig::HEADERS
).body
fs_response = JSON.parse(fs_response)
Typhoeus.put(
fs_response['url'], headers: fs_response['headers'], body: chunk
)
Expand Down Expand Up @@ -261,7 +263,7 @@ def multipart_upload(apikey, filepath, security, options, timeout, intelligent:
)
end
begin
Timeout::timeout(timeout){
Timeout::timeout(timeout) {
while response_complete.code == 202
response_complete = multipart_complete(
apikey, filename, filesize, mimetype,
Expand Down
22 changes: 15 additions & 7 deletions spec/filestack/ruby_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ def initialize(body_content, error_number = 200)
def code
@code
end

def body
@body
end
end


Expand Down Expand Up @@ -78,7 +82,7 @@ def code
upload_id: @start_response[:upload_id],
location_url: @start_response[:location_url]
}
@response = Response.new
@response = GeneralResponse.new(@start_response)
@test_client = FilestackClient.new(@test_apikey)
@test_filelink = FilestackFilelink.new(@test_handle)
@test_security = FilestackSecurity.new(@test_secret)
Expand Down Expand Up @@ -188,7 +192,7 @@ def body
@test_apikey, @test_filename, @test_filesize,
@start_response, @test_security, nil
)
expect(response).to eq('thisissomecontent')
expect(response.to_json).to eq(@response.body)
end

it 'returns the correct create_upload_jobs array' do
Expand All @@ -215,7 +219,7 @@ def body
response = MultipartUploadUtils.upload_chunk(
@job, @test_apikey, @test_filepath, nil
)
expect(response.body).to eq('thisissomecontent')
expect(response.body).to eq(@response.body)
end

it 'returns the correct parallel results' do
Expand Down Expand Up @@ -261,12 +265,16 @@ def code
end

it 'Multipart upload returns the correct response' do
allow(MultipartUploadUtils).to receive(:multipart_upload)
.and_return(@response)
allow_any_instance_of(MultipartUploadUtils).to receive(:multipart_start)
.and_return(@start_response)
allow_any_instance_of(MultipartUploadUtils).to receive(:run_uploads)
.and_return(['somepartsandetags'])
allow_any_instance_of(MultipartUploadUtils).to receive(:multipart_complete)
.and_return(GeneralResponse.new(@start_response))
response = MultipartUploadUtils.multipart_upload(
@test_apikey, @test_filepath
@test_apikey, @test_filepath, nil, nil, 60, intelligent: false
)
expect(response.body).to eq(@response.body)
expect(response.to_json).to eq(@response.body)
end

it 'runs multipart uploads' do
Expand Down

0 comments on commit cc54d68

Please sign in to comment.