uploadcare-ruby 1.0.1.rc1 → 1.0.1.rc2
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/.gitignore +1 -0
- data/README.md +39 -37
- data/lib/uploadcare/version.rb +1 -1
- metadata +3 -3
- data/Gemfile.lock +0 -42
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc5991ac44cf2404d37ae2d374481b9f8bc2c0cc
|
4
|
+
data.tar.gz: 9873a042e14e976d083a6da3f03bfdb3036bd0f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2efd43898961c03cb37287ffef0fd82b89b80a9d0fcfc496fb6876a11524d653d27c21929c08a6ddf05453f3a9304895d77e5d1f8b53df491615d9e9f5e3e00
|
7
|
+
data.tar.gz: cac80a83f934fc8fd21c09057af376712aa2d47c7766c1f10f8bf6f4ac5bcc37f7a396bdc79100dcee760314e9e997b5c69330b825ce8249f8ac87ea0ba6979f
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Gemfile.lock
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
[](http://travis-ci.org/uploadcare/ruby-uploadcare-api)
|
2
2
|
|
3
|
-
A ruby wrapper for uploadcare.com service.
|
3
|
+
A ruby wrapper for [Uploadcare.com](https://uploadcare.com) service.
|
4
4
|
|
5
5
|
|
6
6
|
## Installation
|
@@ -17,7 +17,7 @@ And then execute:
|
|
17
17
|
$ bundle install
|
18
18
|
```
|
19
19
|
|
20
|
-
Or install it yourself
|
20
|
+
Or install it yourself:
|
21
21
|
|
22
22
|
```shell
|
23
23
|
$ gem install uploadcare-ruby
|
@@ -26,7 +26,7 @@ $ gem install uploadcare-ruby
|
|
26
26
|
--
|
27
27
|
|
28
28
|
## Initalizations
|
29
|
-
Just create
|
29
|
+
Just create an API object - and you're good to go.
|
30
30
|
|
31
31
|
```ruby
|
32
32
|
@api = Uploadcare::Api.new(CONFIG)
|
@@ -35,14 +35,14 @@ Just create api object - and you good to go.
|
|
35
35
|
--
|
36
36
|
|
37
37
|
## Raw API
|
38
|
-
Raw API
|
38
|
+
Raw API is a simple interface that allows you to make custom requests to Uploadcare REST API.
|
39
39
|
Just in case you want some low-level control over your app.
|
40
40
|
|
41
41
|
```ruby
|
42
42
|
# any request
|
43
43
|
@api.request :get, "/files/", {page: 2}
|
44
44
|
|
45
|
-
# you
|
45
|
+
# you also have the shortcuts for methods
|
46
46
|
@api.get '/files', {page: 2}
|
47
47
|
|
48
48
|
@api.post ...
|
@@ -52,7 +52,7 @@ Just in case you want some low-level control over your app.
|
|
52
52
|
@api.delete ...
|
53
53
|
|
54
54
|
```
|
55
|
-
All raw API methods
|
55
|
+
All raw API methods return parsed JSON response or raise an error (which you should handle yourself).
|
56
56
|
|
57
57
|
--
|
58
58
|
|
@@ -87,10 +87,10 @@ Use file
|
|
87
87
|
# => "http://www.ucarecdn.com/c969be02-9925-4a7e-aa6d-b0730368791c/"
|
88
88
|
```
|
89
89
|
|
90
|
-
|
90
|
+
Store or delete file
|
91
91
|
|
92
92
|
```ruby
|
93
|
-
# store file (if you dont use autostore
|
93
|
+
# store file (if you dont use autostore option)
|
94
94
|
@uc_file.store
|
95
95
|
# => #<Uploadcare::Api::File ...
|
96
96
|
|
@@ -102,21 +102,21 @@ Keep or delete file
|
|
102
102
|
You can upload either File object (array of files will also cut it) or custom URL.
|
103
103
|
|
104
104
|
### Uploading from URL
|
105
|
-
Just throw your URL into
|
105
|
+
Just throw your URL into API - and you're good to go.
|
106
106
|
|
107
107
|
```ruby
|
108
108
|
# smart upload
|
109
109
|
@file = @api.upload "http://your.awesome/avatar.jpg"
|
110
110
|
# => #<Uploadcare::Api::File ...
|
111
111
|
|
112
|
-
# explicitly upload from
|
112
|
+
# explicitly upload from URL
|
113
113
|
@file = @api.upload_from_url "http://your.awesome/avatar.jpg"
|
114
114
|
# => #<Uploadcare::Api::File ...
|
115
115
|
```
|
116
|
-
Keep in mind that invalid
|
116
|
+
Keep in mind that invalid URL will raise an `ArgumentError`.
|
117
117
|
|
118
118
|
### Uploading a single file
|
119
|
-
Like with URL - just start throwing your file into
|
119
|
+
Like with URL - just start throwing your file into API
|
120
120
|
|
121
121
|
```ruby
|
122
122
|
|
@@ -126,11 +126,11 @@ file = File.open("path/to/your/file.png")
|
|
126
126
|
# => #<Uploadcare::Api::File ...
|
127
127
|
|
128
128
|
```
|
129
|
-
And
|
129
|
+
And that's it.
|
130
130
|
|
131
131
|
### Uploading an array of files
|
132
|
-
Uploading of an array is just as easy as uploading single
|
133
|
-
Note, that every object in array must be an instance of File
|
132
|
+
Uploading of an array is just as easy as uploading a single file.
|
133
|
+
Note, that every object in array must be an instance of `File`.
|
134
134
|
|
135
135
|
```ruby
|
136
136
|
file1 = File.open("path/to/your/file.png")
|
@@ -152,11 +152,8 @@ It is returning you an array of Uploadcare files.
|
|
152
152
|
```
|
153
153
|
|
154
154
|
## File
|
155
|
-
File - is the primary object for Uploadcare API.
|
156
|
-
So all the
|
157
|
-
|
158
|
-
*to do:* way to build file from UUID, CDN URL, and uploading
|
159
|
-
|
155
|
+
`File` - is the primary object for Uploadcare API. Basically it's an avatar for file stored for you ).
|
156
|
+
So all the operations you do - you do it with the file object.
|
160
157
|
|
161
158
|
```ruby
|
162
159
|
@file_to_upload = File.open("your-file.png")
|
@@ -170,14 +167,15 @@ So all the opertations you do - you do it with the file object.
|
|
170
167
|
@uc_file.cdn_url
|
171
168
|
# => "http://www.ucarecdn.com/c969be02-9925-4a7e-aa6d-b0730368791c/"
|
172
169
|
```
|
170
|
+
|
173
171
|
There is one issue with files - all data associated with it accesible with separate HTTP request only.
|
174
|
-
So if don't *specificaly* need image data (like file name, geolocation data etc) - you could just use :uuid and :cdn_url methods for file output:
|
172
|
+
So if don't *specificaly* need image data (like file name, geolocation data etc.) - you could just use :uuid and :cdn_url methods for file output:
|
175
173
|
|
176
174
|
```erb
|
177
175
|
<img src="#{@file.cdn_url}"/>
|
178
176
|
```
|
179
177
|
|
180
|
-
And
|
178
|
+
And that's it. Saves precious loading time.
|
181
179
|
|
182
180
|
If you do however need image data - you could do it manualy:
|
183
181
|
|
@@ -185,7 +183,7 @@ If you do however need image data - you could do it manualy:
|
|
185
183
|
@uc_file.load_data
|
186
184
|
```
|
187
185
|
|
188
|
-
Then your file object will respond to any method, described in API
|
186
|
+
Then your file object will respond to any method, described in API documentation (it basicaly an OpenStruct, so you know what to do):
|
189
187
|
|
190
188
|
```ruby
|
191
189
|
@uc_file.original_filename
|
@@ -195,11 +193,11 @@ Then your file object will respond to any method, described in API documentation
|
|
195
193
|
# => {"width"=>397, "geo_location"=>nil, "datetime_original"=>nil, "height"=>81}
|
196
194
|
```
|
197
195
|
|
198
|
-
You could read more https://uploadcare.com/documentation/rest/#file
|
196
|
+
You could read more: https://uploadcare.com/documentation/rest/#file
|
199
197
|
|
200
198
|
### Generating files from stored info
|
201
199
|
At this point you probably store your files UUIDs or CDN urls in some kind of storage.
|
202
|
-
Then you can
|
200
|
+
Then you can create file object by passing them into API:
|
203
201
|
|
204
202
|
```ruby
|
205
203
|
# file by UUID
|
@@ -216,9 +214,9 @@ Then you can created file object by passing them into API:
|
|
216
214
|
```
|
217
215
|
|
218
216
|
### Operations
|
219
|
-
Uploadcare
|
220
|
-
Version 1.0.0 of
|
221
|
-
For
|
217
|
+
Uploadcare gives you some awesome CDN operations for croping, resizing, rotation, format convertation etc. You could read more at https://uploadcare.com/documentation/cdn/ .
|
218
|
+
Version 1.0.0 of the gem has no specific methods for this kind of operations, we expect to add support for it later in 1.1 releases.
|
219
|
+
For the moment all your file objects can store operations passed by cdn url:
|
222
220
|
|
223
221
|
```ruby
|
224
222
|
@file = @api.file "http://www.ucarecdn.com/a8775cf7-0c2c-44fa-b071-4dd48637ecac/-/crop/150x150/center/-/format/png/"
|
@@ -235,21 +233,21 @@ For now all you files objects can store operations passed by cdn url:
|
|
235
233
|
@file.cdn_url(true)
|
236
234
|
# => "http://www.ucarecdn.com/a8775cf7-0c2c-44fa-b071-4dd48637ecac/-/crop/150x150/center/-/format/png/"
|
237
235
|
|
238
|
-
# or
|
236
|
+
# or call specific methods for url with or without them:
|
239
237
|
@file.cdn_url_with_operations
|
240
238
|
@file.cdn_url_without_operations
|
241
239
|
```
|
242
240
|
|
243
|
-
Until operations wrapper is released best way for you to manage operation is simply add them to
|
241
|
+
Until operations wrapper is released the best way for you to manage operation is simply add them to URL as a string:
|
244
242
|
|
245
243
|
```ruby
|
246
244
|
<img src="#{file.cdn_url}-/crop/#{width}x#{height}/center/"/>
|
247
245
|
# or something like that
|
248
246
|
```
|
249
247
|
|
250
|
-
##
|
251
|
-
File
|
252
|
-
In our gem file list is a single page containing 20 (by default, value may change) files and some methods for
|
248
|
+
## File list and pagination
|
249
|
+
File list is a paginated collection of files for you project. You could read more at https://uploadcare.com/documentation/rest/#pagination.
|
250
|
+
In our gem file list is a single page containing 20 (by default, value may change) files and some methods for navigating through pages.
|
253
251
|
|
254
252
|
```ruby
|
255
253
|
@list = @api.file_list 1 #page number, 1 by default
|
@@ -278,7 +276,7 @@ In our gem file list is a single page containing 20 (by default, value may chang
|
|
278
276
|
# => #<Uploadcare::Api::File ....
|
279
277
|
```
|
280
278
|
|
281
|
-
And don't forget
|
279
|
+
And don't forget that you can navigate throught pages:
|
282
280
|
|
283
281
|
```ruby
|
284
282
|
@list = @api.files_list 3
|
@@ -314,7 +312,9 @@ And don't forget navigation throught pages:
|
|
314
312
|
|
315
313
|
## Project
|
316
314
|
Project provides basic information about the connecting project.
|
317
|
-
Project object is basicly openstruct so every method described in
|
315
|
+
Project object is basicly openstruct so every method described in
|
316
|
+
[API docs](https://uploadcare.com/documentation/rest/#project)
|
317
|
+
accessible to you:
|
318
318
|
|
319
319
|
```ruby
|
320
320
|
project = @api.project
|
@@ -333,7 +333,7 @@ p.collaborators
|
|
333
333
|
## Groups of files
|
334
334
|
Groups of files - https://uploadcare.com/documentation/rest/#group.
|
335
335
|
Stores files as group by the single UUID.
|
336
|
-
Note that UUID has a
|
336
|
+
Note that UUID has a `~#{files_count}` part at the end and it is required by API to work properly.
|
337
337
|
|
338
338
|
```ruby
|
339
339
|
# group can be created eather by array of Uploadcare Files:
|
@@ -351,7 +351,7 @@ Note that UUID has a bit ~#{files_count} at the end and it is required by API to
|
|
351
351
|
@group_uloaded = @api.group "#{uuid}"
|
352
352
|
```
|
353
353
|
|
354
|
-
As with files, group created by passing just the UUID is not loaded by default - you need to load data
|
354
|
+
As with files, group created by passing just the UUID is not loaded by default - you need to load data manually, as it requires separate HTTP GET request.
|
355
355
|
New groups created by :create_group method is loaded by default.
|
356
356
|
|
357
357
|
```ruby
|
@@ -383,3 +383,5 @@ private_key: 'PRIVATE KEY'
|
|
383
383
|
```
|
384
384
|
|
385
385
|
## Contributing
|
386
|
+
|
387
|
+
This is open source, fork, hack, request a pull, receive a discount)
|
data/lib/uploadcare/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uploadcare-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.1.
|
4
|
+
version: 1.0.1.rc2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- '@rastyagaev (Vadim Rastyagaev)'
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2014-03-08 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: faraday
|
@@ -106,8 +106,8 @@ extensions: []
|
|
106
106
|
extra_rdoc_files: []
|
107
107
|
files:
|
108
108
|
- .DS_Store
|
109
|
+
- .gitignore
|
109
110
|
- Gemfile
|
110
|
-
- Gemfile.lock
|
111
111
|
- LICENSE
|
112
112
|
- README.md
|
113
113
|
- Rakefile
|
data/Gemfile.lock
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
uploadcare-ruby (1.0.0)
|
5
|
-
faraday
|
6
|
-
faraday_middleware
|
7
|
-
mime-types
|
8
|
-
multipart-post
|
9
|
-
|
10
|
-
GEM
|
11
|
-
remote: https://rubygems.org/
|
12
|
-
specs:
|
13
|
-
coderay (1.0.9)
|
14
|
-
diff-lcs (1.2.4)
|
15
|
-
faraday (0.8.8)
|
16
|
-
multipart-post (~> 1.2.0)
|
17
|
-
faraday_middleware (0.9.0)
|
18
|
-
faraday (>= 0.7.4, < 0.9)
|
19
|
-
method_source (0.8.2)
|
20
|
-
mime-types (2.0)
|
21
|
-
multipart-post (1.2.0)
|
22
|
-
pry (0.9.12.2)
|
23
|
-
coderay (~> 1.0.5)
|
24
|
-
method_source (~> 0.8)
|
25
|
-
slop (~> 3.4)
|
26
|
-
rspec (2.14.1)
|
27
|
-
rspec-core (~> 2.14.0)
|
28
|
-
rspec-expectations (~> 2.14.0)
|
29
|
-
rspec-mocks (~> 2.14.0)
|
30
|
-
rspec-core (2.14.7)
|
31
|
-
rspec-expectations (2.14.3)
|
32
|
-
diff-lcs (>= 1.1.3, < 2.0)
|
33
|
-
rspec-mocks (2.14.4)
|
34
|
-
slop (3.4.6)
|
35
|
-
|
36
|
-
PLATFORMS
|
37
|
-
ruby
|
38
|
-
|
39
|
-
DEPENDENCIES
|
40
|
-
pry
|
41
|
-
rspec
|
42
|
-
uploadcare-ruby!
|