Skip to content

Commit

Permalink
Merge pull request #126 from uploadcare/4.3.5
Browse files Browse the repository at this point in the history
Version 4.3.5
  • Loading branch information
rsedykh authored Sep 19, 2023
2 parents 2d4f76c + d46e614 commit a6b961a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 13 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## 4.3.5 — 2023-09-19

### Changed

* Updated behavior to exclude sending blank values in the `store` param.


## 4.3.4 — 2023-05-16

### Changed
Expand Down
15 changes: 9 additions & 6 deletions lib/uploadcare/client/uploader_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,21 +94,24 @@ def upload_many_body(arr, options = {})
)
end

STORE_VALUES_MAP = {
true => '1',
false => '0'
}.freeze

# Prepare upload_from_url initial request body
def upload_from_url_body(url, options = {})
HTTP::FormData::Multipart.new(
options.merge(
'pub_key' => Uploadcare.config.public_key,
'source_url' => url,
'store' => STORE_VALUES_MAP[options[:store]]
'store' => store_value(options[:store])
)
)
end

def store_value(store)
case store
when true, '1', 1 then '1'
when false, '0', 0 then '0'
else 'auto'
end
end
end
end
end
13 changes: 7 additions & 6 deletions lib/uploadcare/param/upload/upload_params_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,19 @@ class << self
def call(options = {})
{
'UPLOADCARE_PUB_KEY' => Uploadcare.config.public_key,
'UPLOADCARE_STORE' => store(options[:store]),
'UPLOADCARE_STORE' => store_value(options[:store]),
'signature' => (Upload::SignatureGenerator.call if Uploadcare.config.sign_uploads)
}.merge(metadata(options)).compact
end

private

def store(store)
store = 'auto' if store.nil?
store = '0' if store == false
store = '1' if store == true
store
def store_value(store)
case store
when true, '1', 1 then '1'
when false, '0', 0 then '0'
else 'auto'
end
end

def metadata(options = {})
Expand Down
2 changes: 1 addition & 1 deletion lib/uploadcare/ruby/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Uploadcare
VERSION = '4.3.4'
VERSION = '4.3.5'
end

0 comments on commit a6b961a

Please sign in to comment.