Skip to content

Commit 4144aee

Browse files
committed
Strip upload object and xml support
1 parent 8241896 commit 4144aee

10 files changed

Lines changed: 11 additions & 42 deletions

File tree

cloudconvert.gemspec

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ Gem::Specification.new do |spec|
2121
spec.add_dependency "json"
2222
spec.add_dependency "memoizable", "~> 0.4.0"
2323
spec.add_dependency "mimemagic", "~> 0.3.5"
24-
spec.add_dependency "multi_xml"
2524
spec.add_dependency "openssl"
2625
spec.add_dependency "ostruct"
2726
spec.add_dependency "schemacop", "~> 2.4"

lib/cloudconvert.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
require "cloudconvert/resources/tasks"
2626
require "cloudconvert/resources/users"
2727
require "cloudconvert/task"
28-
require "cloudconvert/upload"
2928
require "cloudconvert/user"
3029
require "cloudconvert/version"
3130
require "cloudconvert/webhook"

lib/cloudconvert/client.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ def connection
9292
f.request :json
9393
f.request :multipart
9494
f.use CloudConvert::Middleware::ParseJson, content_type: /\bjson$/
95-
f.use CloudConvert::Middleware::ParseXml, content_type: /\bxml$/
9695
end
9796
end
9897

lib/cloudconvert/middleware.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,5 @@ class ParseJson < FaradayMiddleware::ParseJson
55
JSON.parse(body, object_class: OpenStruct) unless body.blank?
66
end
77
end
8-
9-
ParseXml = Class.new(FaradayMiddleware::ParseXml)
108
end
119
end

lib/cloudconvert/resources/tasks.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def wait(id)
5656

5757
# @param file [File, String, IO] Either a String filename to a local file or an open IO object.
5858
# @param task [Task] The "import/upload" Task to upload the file to.
59-
# @return [Upload]
59+
# @return [void]
6060
def upload(file, task)
6161
unless task.operation == "import/upload"
6262
raise ArgumentError.new("The task operation is not import/upload")
@@ -68,12 +68,12 @@ def upload(file, task)
6868

6969
file = File.new(file) unless file.is_a? File
7070

71-
response = client.post(task.result.form.url, task.result.form.parameters.to_h.merge(file: file)) do |request|
71+
client.post(task.result.form.url, task.result.form.parameters.to_h.merge(file: file)) do |request|
7272
request.headers.delete("Authorization")
7373
request.headers["Content-Type"] = "multipart/form-data"
7474
end
7575

76-
Upload.new Hash[*response["PostResponse"].flat_map { |k, v| [k.downcase.to_sym, v] }]
76+
nil
7777
end
7878
end
7979
end

lib/cloudconvert/upload.rb

Lines changed: 0 additions & 6 deletions
This file was deleted.

spec/fixtures/responses/upload_completed.xml

Lines changed: 0 additions & 7 deletions
This file was deleted.

spec/integration/jobs_spec.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@
3131
import_task = cloudconvert.tasks.find(import_task.id)
3232

3333
# do upload
34-
upload = cloudconvert.tasks.upload(File.expand_path("files/input.pdf", __dir__), import_task)
35-
expect(upload.location).to match %r{^https://storage.cloudconvert.com/tasks-sandbox}
34+
cloudconvert.tasks.upload(File.expand_path("files/input.pdf", __dir__), import_task)
3635

3736
# fetch the finished export task
3837
export_task = cloudconvert.tasks.wait(export_task.id)

spec/integration/tasks_spec.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
})
1616

1717
# upload file
18-
upload = cloudconvert.tasks.upload(File.expand_path("files/input.pdf", __dir__), @task)
19-
expect(upload.location).to match %r{^https://storage.cloudconvert.com/tasks-sandbox}
18+
cloudconvert.tasks.upload(File.expand_path("files/input.pdf", __dir__), @task)
2019

2120
# wait for the task
2221
@task = cloudconvert.tasks.wait(@task.id)

spec/resources/tasks_spec.rb

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -199,15 +199,11 @@
199199
})
200200

201201
stub_post(form_url)
202-
# .with({
203-
# WebMock does not support matching body for multipart/form-data requests yet :(
204-
# body: form_parameters.merge(file: Faraday::FilePart.new(file, content_type)),
205-
# headers: { content_type: "multipart/form-data" },
206-
# })
207-
.to_return({
208-
body: fixture("responses/upload_completed.xml"),
209-
headers: { content_type: "application/xml" },
210-
})
202+
# .with({
203+
# WebMock does not support matching body for multipart/form-data requests yet :(
204+
# body: form_parameters.merge(file: CloudConvert::File.new(file)),
205+
# headers: { content_type: "multipart/form-data" },
206+
# })
211207
end
212208

213209
let(:form_url) do
@@ -238,14 +234,7 @@
238234
it "requests the correct resource" do
239235
expect(a_post("/v2/import/upload")).to have_been_made
240236
expect(a_post(form_url)).to have_been_made
241-
end
242-
243-
it "returns the upload" do
244-
expect(upload).to be_a CloudConvert::Upload
245-
expect(upload.bucket).to eq "tasks-sandbox"
246-
expect(upload.key).to eq "ff745ae9-5352-4b34-8c18-c2f23a583f1a/input.pdf"
247-
expect(upload.etag).to eq '"53d6fe6b688c31c565907c81de625046"'
248-
expect(upload.location).to eq "https://storage.cloudconvert.com/tasks-sandbox/ff745ae9-5352-4b34-8c18-c2f23a583f1a/input.pdf"
237+
expect(upload).to be nil
249238
end
250239
end
251240

0 commit comments

Comments
 (0)