uploadcare-ruby 3.1.0 → 3.1.1
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 +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +8 -14
- data/lib/uploadcare/client/project_client.rb +1 -1
- data/lib/uploadcare/entity/decorator/paginator.rb +1 -1
- data/lib/uploadcare/entity/file.rb +11 -0
- data/lib/uploadcare/ruby/version.rb +1 -1
- data/uploadcare-ruby.gemspec +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50f31851c1ededcc13b14099d5451a2cae8ad1a1c36ce45bbe47447fc536dc3a
|
4
|
+
data.tar.gz: 0c5eecb5f2583645455230fb5679c65612e322a4dcae82cae97e5b9fc702dab4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a1c5aef9d35b915e2a691ecaed88a1687bba7c7692e6c5066999e1348c5ba0bc9fe76e4afd3eea08da72b57f9a58379a7fc287385a316c6a12e795005e9b66e
|
7
|
+
data.tar.gz: 44a5eb8c106bd7b803428d4d8c7ad056b723dfc014baa4e94fd390c0924732a14b3d7ad9e262fa6e7de02a75bca073ee19b8476eda64c86b6fee1817380124c5
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -91,7 +91,7 @@ Using Uploadcare is simple, and here are the basics of handling files.
|
|
91
91
|
# => "dc99200d-9bd6-4b43-bfa9-aa7bfaefca40"
|
92
92
|
|
93
93
|
# URL for the file, can be used with your website or app right away
|
94
|
-
@uc_file.
|
94
|
+
@uc_file.url
|
95
95
|
# => "https://ucarecdn.com/dc99200d-9bd6-4b43-bfa9-aa7bfaefca40/"
|
96
96
|
```
|
97
97
|
|
@@ -184,11 +184,6 @@ You can override global [`:autostore`](#initialization) option for each upload r
|
|
184
184
|
```
|
185
185
|
|
186
186
|
### File management
|
187
|
-
Most methods are also available through `Uploadcare::Api` object:
|
188
|
-
```ruby
|
189
|
-
# Same as Uploadcare::Uploader.upload
|
190
|
-
Uploadcare::Api.upload("https://placekitten.com/96/139")
|
191
|
-
```
|
192
187
|
|
193
188
|
Entities are representations of objects in Uploadcare cloud.
|
194
189
|
|
@@ -273,13 +268,13 @@ Metadata of deleted files is stored permanently.
|
|
273
268
|
|
274
269
|
#### FileList
|
275
270
|
|
276
|
-
`Uploadcare::
|
271
|
+
`Uploadcare::FileList` represents the whole collection of files (or it's
|
277
272
|
subset) and provides a way to iterate through it, making pagination transparent.
|
278
|
-
FileList objects can be created using `Uploadcare::
|
273
|
+
FileList objects can be created using `Uploadcare::FileList.file_list` method.
|
279
274
|
|
280
275
|
```ruby
|
281
|
-
@list = Uploadcare::
|
282
|
-
# Returns instance of Uploadcare::
|
276
|
+
@list = Uploadcare::FileList.file_list
|
277
|
+
# Returns instance of Uploadcare::Entity::FileList
|
283
278
|
<Hashie::Mash
|
284
279
|
next=nil
|
285
280
|
per_page=100
|
@@ -294,7 +289,7 @@ FileList objects can be created using `Uploadcare::Entity.file_list` method.
|
|
294
289
|
@all_files = @list.load
|
295
290
|
```
|
296
291
|
|
297
|
-
This method accepts some options to
|
292
|
+
This method accepts some options to control which files should be fetched and
|
298
293
|
how they should be fetched:
|
299
294
|
|
300
295
|
- **:limit** — Controls page size. Accepts values from 1 to 1000, defaults to 100.
|
@@ -326,11 +321,11 @@ To simply get all associated objects:
|
|
326
321
|
|
327
322
|
Initially, `FileList` is a paginated collection. It can be navigated using following methods:
|
328
323
|
```ruby
|
329
|
-
@file_list = Uploadcare::
|
324
|
+
@file_list = Uploadcare::FileList.file_list
|
330
325
|
# Let's assume there are 250 files in cloud. By default, UC loads 100 files. To get next 100 files, do:
|
331
326
|
@next_page = @file_list.next_page
|
332
327
|
# To get previous page:
|
333
|
-
@previous_page = @
|
328
|
+
@previous_page = @file_list.previous_page
|
334
329
|
```
|
335
330
|
|
336
331
|
Alternatively, it's possible to iterate through full list of groups or files with `each`:
|
@@ -351,7 +346,6 @@ That's a requirement of our API.
|
|
351
346
|
@file = "134dc30c-093e-4f48-a5b9-966fe9cb1d01"
|
352
347
|
@file2 = "134dc30c-093e-4f48-a5b9-966fe9cb1d02"
|
353
348
|
@files_ary = [@file, @file2]
|
354
|
-
@files = Uploadcare::Uploader.upload @files_ary
|
355
349
|
@group = Uploadcare::Group.create @files
|
356
350
|
|
357
351
|
# group can be stored by group ID. It means that all files of a group will be stored on Uploadcare servers permanently
|
@@ -6,7 +6,7 @@ module Uploadcare
|
|
6
6
|
# @see https://uploadcare.com/docs/api_reference/rest/handling_projects/
|
7
7
|
class ProjectClient < RestClient
|
8
8
|
# get information about current project
|
9
|
-
# current project is determined by public and
|
9
|
+
# current project is determined by public and secret key combination
|
10
10
|
# @see https://uploadcare.com/api-refs/rest-api/v0.5.0/#tag/Project
|
11
11
|
def show
|
12
12
|
get(uri: '/project/')
|
@@ -44,7 +44,7 @@ module Uploadcare
|
|
44
44
|
#
|
45
45
|
# It's possible to avoid loading objects on previous pages by offsetting them first
|
46
46
|
def load
|
47
|
-
return if @entity[:next].nil? || @entity[:results].length == @entity[:total]
|
47
|
+
return self if @entity[:next].nil? || @entity[:results].length == @entity[:total]
|
48
48
|
|
49
49
|
np = self
|
50
50
|
until np.next.nil?
|
@@ -91,6 +91,17 @@ module Uploadcare
|
|
91
91
|
File.copy(uuid, target: target, **args)
|
92
92
|
end
|
93
93
|
|
94
|
+
# Store a single file, preventing it from being deleted in 2 weeks
|
95
|
+
# @see https://uploadcare.com/api-refs/rest-api/v0.5.0/#operation/storeFile
|
96
|
+
def store
|
97
|
+
File.store(uuid)
|
98
|
+
end
|
99
|
+
|
100
|
+
# @see https://uploadcare.com/api-refs/rest-api/v0.5.0/#operation/deleteFile
|
101
|
+
def delete
|
102
|
+
File.delete(uuid)
|
103
|
+
end
|
104
|
+
|
94
105
|
private
|
95
106
|
|
96
107
|
def convert_file(params, converter, options = {})
|
data/uploadcare-ruby.gemspec
CHANGED
@@ -38,7 +38,7 @@ Gem::Specification.new do |spec|
|
|
38
38
|
spec.require_paths = ['lib', 'lib/uploadcare', 'lib/uploadcare/rest']
|
39
39
|
|
40
40
|
spec.add_dependency 'api_struct', '~> 1.0.1'
|
41
|
-
spec.add_dependency 'dry-configurable', '~> 0.9
|
41
|
+
spec.add_dependency 'dry-configurable', '~> 0.9'
|
42
42
|
spec.add_dependency 'parallel'
|
43
43
|
spec.add_dependency 'retries'
|
44
44
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uploadcare-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.
|
4
|
+
version: 3.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stepan Redka
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: api_struct
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.9
|
33
|
+
version: '0.9'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.9
|
40
|
+
version: '0.9'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: parallel
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -241,7 +241,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
241
241
|
- !ruby/object:Gem::Version
|
242
242
|
version: '0'
|
243
243
|
requirements: []
|
244
|
-
rubygems_version: 3.
|
244
|
+
rubygems_version: 3.2.22
|
245
245
|
signing_key:
|
246
246
|
specification_version: 4
|
247
247
|
summary: Ruby wrapper for uploadcare API
|