filestack 2.5.3 → 2.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0b7d3ba72df49cc4fd9149008f780ada8d2e0aa4
4
- data.tar.gz: 82c84956bbedf392a56c4ef5a2ba160ed69f0a8a
3
+ metadata.gz: df82fcab255164aa2495b536833524af2dc53a88
4
+ data.tar.gz: 63e1a01506b9b407f9e616835aa3a86c50dd38ff
5
5
  SHA512:
6
- metadata.gz: d51fc97148fc3f95c82d57102b8662fdd8489da4d61ff52c395cef2a7b0df064e3bdc53567a5fd2fbdff88a5af171013e94e428c5f49db78eb7d18aa0b9a2250
7
- data.tar.gz: f9737bbf117c1f5919fd945e6aef60e3ed1888b12a171789f16d25871f249494b557429c1e7668e7bda718477bb1353e7e5231ca30d01228d86507529395f8c5
6
+ metadata.gz: a4df97fd84c2044647fcb82bbfeeaedb185725fb1d3bc1b6018b358c6ff1124c06d69471b4777ba9f05c760d9db36b0be089e458043b244a65bea28a754801a4
7
+ data.tar.gz: d524e4b2f95f5d8b4e61884e738991c96658f2e9fa233261904e51708a99152fbce4d4828cf9d09394d23e04ea51798538598b2673f097be211b98829f592576
@@ -1,5 +1,8 @@
1
1
  # Filestack-Ruby Changelog
2
2
 
3
+ ## 2.5.4 (February 12, 2019)
4
+ - Fixed issue with multipart upload
5
+
3
6
  ## 2.5.3 (January 18, 2019)
4
7
  - Fixed issue with upload with passed params (mimetype, path, etc.) for external url
5
8
 
data/README.md CHANGED
@@ -52,11 +52,28 @@ Filestack uses multipart uploading by default, which is faster for larger files.
52
52
  ```ruby
53
53
  filelink = client.upload(filepath: '/path/to/file')
54
54
 
55
+ filelink = client.upload(filepath: '/path/to/file', multipart: false)
56
+
55
57
  # OR
56
58
 
57
59
  filelink = client.upload(external_url: 'http://someurl.com')
58
60
  ```
59
61
 
62
+ To upload a local and an external file with query parameters:
63
+ ```ruby
64
+ filelink = client.upload(filepath: '/path/to/file', options: {mimetype: 'image/png'})
65
+
66
+ filelink = client.upload(external_url: 'http://someurl.com/image.png', options: {mimetype: 'image/jpeg'})
67
+ ```
68
+
69
+ To store file on `dropbox`, `azure`, `gcs` or `rackspace`, you must have the chosen provider configured in the developer portal to enable this feature. By default the file is stored on `s3`. You can add more details of the storage in `options`.
70
+
71
+ ```ruby
72
+ filelink = client.upload(filepath: '/path/to/file', storage: 'dropbox', options: {path: 'folder_name/'})
73
+
74
+ filelink = client.upload(external_url: 'http://someurl.com/image.png', storage: 'dropbox', options: {path: 'folder_name/'})
75
+ ```
76
+
60
77
  ### Security
61
78
  If security is enabled on your account, or if you are using certain actions that require security (delete, overwrite and certain transformations), you will need to create a security object and pass it into the client on instantiation.
62
79
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.5.3
1
+ 2.5.4
@@ -31,12 +31,12 @@ class FilestackClient
31
31
  # @param [Hash] options User-supplied upload options
32
32
  #
33
33
  # return [Filestack::FilestackFilelink]
34
- def upload(filepath: nil, external_url: nil, multipart: true, options: nil, storage: 's3', intelligent: false, timeout: 60)
34
+ def upload(filepath: nil, external_url: nil, multipart: true, options: {}, storage: 's3', intelligent: false, timeout: 60)
35
35
  if filepath && external_url
36
36
  return 'You cannot upload a URL and file at the same time'
37
37
  end
38
38
  response = if filepath && multipart
39
- multipart_upload(@apikey, filepath, @security, options, timeout, intelligent: intelligent)
39
+ multipart_upload(@apikey, filepath, @security, options, timeout, storage, intelligent: intelligent)
40
40
  else
41
41
  send_upload(
42
42
  @apikey,
@@ -49,20 +49,20 @@ class FilestackClient
49
49
  end
50
50
  FilestackFilelink.new(response['handle'], security: @security, apikey: @apikey)
51
51
  end
52
- # Transform an external URL
52
+ # Transform an external URL
53
53
  #
54
- # @param [string] external_url A valid URL
54
+ # @param [string] external_url A valid URL
55
55
  #
56
56
  # @return [Filestack::Transform]
57
57
  def transform_external(external_url)
58
58
  Transform.new(external_url: external_url, security: @security, apikey: @apikey)
59
- end
59
+ end
60
60
 
61
- def zip(destination, files)
61
+ def zip(destination, files)
62
62
  encoded_files = JSON.generate(files).gsub('"', '')
63
63
  zip_url = "#{FilestackConfig::CDN_URL}/#{@apikey}/zip/#{encoded_files}"
64
64
  escaped_zip_url = zip_url.gsub("[","%5B").gsub("]","%5D")
65
- response = UploadUtils.make_call(escaped_zip_url, 'get')
65
+ response = UploadUtils.make_call(escaped_zip_url, 'get')
66
66
  File.write(destination, response.body)
67
67
  end
68
68
  end
@@ -1,5 +1,5 @@
1
1
  module Filestack
2
2
  module Ruby
3
- VERSION = '2.5.3'.freeze
3
+ VERSION = '2.5.4'.freeze
4
4
  end
5
5
  end
@@ -23,6 +23,16 @@ module MultipartUploadUtils
23
23
  [filename, filesize, mimetype.to_s]
24
24
  end
25
25
 
26
+ def multipart_options(options)
27
+ [:region, :container, :path, :access].each do |key|
28
+ if options.has_key?(key)
29
+ options[:"store_#{key}"] = options[key]
30
+ options.delete(key)
31
+ end
32
+ end
33
+ return options
34
+ end
35
+
26
36
  # Send start response to multipart endpoint
27
37
  #
28
38
  # @param [String] apikey Filestack API key
@@ -35,17 +45,17 @@ module MultipartUploadUtils
35
45
  # multipart uploads
36
46
  #
37
47
  # @return [Typhoeus::Response]
38
- def multipart_start(apikey, filename, filesize, mimetype, security, options)
48
+ def multipart_start(apikey, filename, filesize, mimetype, security, storage, options = {})
39
49
  params = {
40
50
  apikey: apikey,
41
51
  filename: filename,
42
52
  mimetype: mimetype,
43
53
  size: filesize,
44
- store_location: options.nil? ? 's3' : options[:store_location],
54
+ store_location: storage,
45
55
  file: Tempfile.new(filename),
46
- options: options,
47
56
  'multipart' => 'true'
48
57
  }
58
+ options = multipart_options(options)
49
59
  params = params.merge!(options) if options
50
60
 
51
61
  unless security.nil?
@@ -76,7 +86,7 @@ module MultipartUploadUtils
76
86
  # multipart uploads
77
87
  #
78
88
  # @return [Array]
79
- def create_upload_jobs(apikey, filename, filepath, filesize, start_response, options)
89
+ def create_upload_jobs(apikey, filename, filepath, filesize, start_response, storage, options)
80
90
  jobs = []
81
91
  part = 1
82
92
  seek_point = 0
@@ -93,9 +103,11 @@ module MultipartUploadUtils
93
103
  upload_id: start_response['upload_id'],
94
104
  location_url: start_response['location_url'],
95
105
  start_response: start_response,
96
- options: options,
97
- store_location: options.nil? ? 's3' : options[:store_location]
106
+ store_location: storage
98
107
  }
108
+ options = multipart_options(options)
109
+ part_info = part_info.merge!(options) if options
110
+
99
111
  if seek_point + FilestackConfig::DEFAULT_CHUNK_SIZE > filesize
100
112
  size = filesize - (seek_point)
101
113
  else
@@ -191,7 +203,7 @@ module MultipartUploadUtils
191
203
  # multipart uploads
192
204
  #
193
205
  # @return [Typhoeus::Response]
194
- def multipart_complete(apikey, filename, filesize, mimetype, start_response, parts_and_etags, options, intelligent = false)
206
+ def multipart_complete(apikey, filename, filesize, mimetype, start_response, parts_and_etags, options, storage, intelligent = false)
195
207
  if !intelligent
196
208
  data = {
197
209
  apikey: apikey,
@@ -202,7 +214,7 @@ module MultipartUploadUtils
202
214
  size: filesize,
203
215
  mimetype: mimetype,
204
216
  parts: parts_and_etags.join(';'),
205
- store_location: options.nil? ? 's3' : options[:store_location],
217
+ store_location: storage,
206
218
  file: Tempfile.new(filename)
207
219
  }
208
220
  else
@@ -214,11 +226,12 @@ module MultipartUploadUtils
214
226
  filename: filename,
215
227
  size: filesize,
216
228
  mimetype: mimetype,
217
- store_location: options.nil? ? 's3' : options[:store_location],
229
+ store_location: storage,
218
230
  file: Tempfile.new(filename),
219
231
  'multipart' => 'true'
220
232
  }
221
233
  end
234
+ options = multipart_options(options)
222
235
  data = data.merge!(options) if options
223
236
 
224
237
  Typhoeus.post(
@@ -237,29 +250,32 @@ module MultipartUploadUtils
237
250
  # multipart uploads
238
251
  #
239
252
  # @return [Hash]
240
- def multipart_upload(apikey, filepath, security, options, timeout, intelligent: false)
253
+ def multipart_upload(apikey, filepath, security, options, timeout, storage, intelligent: false)
241
254
  filename, filesize, mimetype = get_file_info(filepath)
242
255
  start_response = multipart_start(
243
- apikey, filename, filesize, mimetype, security, options
256
+ apikey, filename, filesize, mimetype, security, storage, options
244
257
  )
258
+
245
259
  unless start_response['upload_type'].nil?
246
260
  intelligent_enabled = ((start_response['upload_type'].include? 'intelligent_ingestion')) && intelligent
247
261
  end
262
+
248
263
  jobs = create_upload_jobs(
249
- apikey, filename, filepath, filesize, start_response, options
264
+ apikey, filename, filepath, filesize, start_response, storage, options
250
265
  )
266
+
251
267
  if intelligent_enabled
252
268
  state = IntelligentState.new
253
269
  run_intelligent_upload_flow(jobs, state)
254
270
  response_complete = multipart_complete(
255
271
  apikey, filename, filesize, mimetype,
256
- start_response, nil, options, intelligent
272
+ start_response, nil, options, storage, intelligent
257
273
  )
258
274
  else
259
275
  parts_and_etags = run_uploads(jobs, apikey, filepath, options)
260
276
  response_complete = multipart_complete(
261
277
  apikey, filename, filesize, mimetype,
262
- start_response, parts_and_etags, options
278
+ start_response, parts_and_etags, options, storage
263
279
  )
264
280
  end
265
281
  begin
@@ -267,7 +283,7 @@ module MultipartUploadUtils
267
283
  while response_complete.code == 202
268
284
  response_complete = multipart_complete(
269
285
  apikey, filename, filesize, mimetype,
270
- start_response, nil, options, intelligent
286
+ start_response, nil, options, storage, intelligent
271
287
  )
272
288
  end
273
289
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: filestack
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.3
4
+ version: 2.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Filestack
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-01-18 00:00:00.000000000 Z
11
+ date: 2019-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typhoeus