filestack 2.1.0 → 2.2.0

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.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +3 -0
  3. data/README.md +2 -2
  4. data/VERSION +1 -1
  5. data/docs/AV.html +557 -0
  6. data/docs/Filestack.html +115 -0
  7. data/docs/Filestack/Ruby.html +115 -0
  8. data/docs/FilestackClient.html +702 -0
  9. data/docs/FilestackCommon.html +884 -0
  10. data/docs/FilestackConfig.html +197 -0
  11. data/docs/FilestackFilelink.html +1277 -0
  12. data/docs/FilestackSecurity.html +654 -0
  13. data/docs/IntelligentState.html +729 -0
  14. data/docs/IntelligentUtils.html +1639 -0
  15. data/docs/MultipartUploadUtils.html +1543 -0
  16. data/docs/Transform.html +1152 -0
  17. data/docs/TransformConfig.html +138 -0
  18. data/docs/TransformUtils.html +272 -0
  19. data/docs/UploadUtils.html +673 -0
  20. data/docs/_index.html +227 -0
  21. data/docs/class_list.html +51 -0
  22. data/docs/css/common.css +1 -0
  23. data/docs/css/full_list.css +58 -0
  24. data/docs/css/style.css +492 -0
  25. data/docs/file.README.html +210 -0
  26. data/docs/file_list.html +56 -0
  27. data/docs/frames.html +17 -0
  28. data/docs/index.html +210 -0
  29. data/docs/js/app.js +248 -0
  30. data/docs/js/full_list.js +216 -0
  31. data/docs/js/jquery.js +4 -0
  32. data/docs/method_list.html +643 -0
  33. data/docs/top-level-namespace.html +145 -0
  34. data/examples/file_transformations.rb +6 -0
  35. data/examples/intelligent_upload.rb +7 -0
  36. data/examples/normal_upload.rb +5 -0
  37. data/examples/upload_external_url.rb +7 -0
  38. data/examples/upload_with_security.rb +6 -0
  39. data/examples/video_convert.rb +10 -0
  40. data/filestack-ruby.gemspec +1 -0
  41. data/lib/filestack/config.rb +9 -5
  42. data/lib/filestack/mixins/filestack_common.rb +17 -1
  43. data/lib/filestack/models/filelink.rb +8 -1
  44. data/lib/filestack/models/filestack_client.rb +17 -3
  45. data/lib/filestack/ruby/version.rb +1 -1
  46. data/lib/filestack/utils/multipart_upload_utils.rb +91 -36
  47. data/lib/filestack/utils/utils.rb +309 -1
  48. metadata +52 -3
@@ -0,0 +1,210 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ File: README
8
+
9
+ &mdash; Documentation by YARD 0.9.9
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ pathId = "README";
19
+ relpath = '';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="file_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="_index.html">Index</a> &raquo;
40
+ <span class="title">File: README</span>
41
+
42
+ </div>
43
+
44
+ <div id="search">
45
+
46
+ <a class="full_list_link" id="class_list_link"
47
+ href="class_list.html">
48
+
49
+ <svg width="24" height="24">
50
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
51
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
52
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
53
+ </svg>
54
+ </a>
55
+
56
+ </div>
57
+ <div class="clear"></div>
58
+ </div>
59
+
60
+ <div id="content"><div id='filecontents'><p><a href="http://travis-ci.org/filestack/filestack-ruby"><img src="https://travis-ci.org/filestack/filestack-ruby.svg?branch=master%09%09" alt="Travis CI"></a>
61
+ <a href="https://coveralls.io/github/filestack/filestack-ruby?branch=master%09%09"><img src="https://coveralls.io/repos/github/filestack/filestack-ruby/badge.svg?branch=master" alt="Coveralls"></a>
62
+ <a href="https://codeclimate.com/github/filestack/filestack-ruby%09%09"><img src="https://codeclimate.com/github/filestack/filestack-ruby.png%09%09" alt="Code Climate"></a></p>
63
+
64
+ <h1>Filestack Ruby SDK</h1>
65
+
66
+ <p><a href="https://www.filestack.com"><img src="https://filestack.com/themes/filestack/assets/images/press-articles/color.svg" align="left" hspace="10" vspace="6"></a>
67
+ This is the official Ruby SDK for Filestack - API and content management system that makes it easy to add powerful file uploading and transformation capabilities to any web or mobile application.</p>
68
+
69
+ <h2>Resources</h2>
70
+
71
+ <ul>
72
+ <li><a href="https://www.filestack.com">Filestack</a></li>
73
+ <li><a href="https://www.filestack.com/docs">Documentation</a></li>
74
+ <li><a href="https://filestack.github.io/">API Reference</a></li>
75
+ </ul>
76
+
77
+ <h2>Installing</h2>
78
+
79
+ <p>Add this line to your application&#39;s Gemfile:</p>
80
+
81
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_gem'>gem</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>filestack</span><span class='tstring_end'>&#39;</span></span>
82
+ </code></pre>
83
+
84
+ <p>And then execute:</p>
85
+
86
+ <pre class="code ruby"><code class="ruby">$ bundle
87
+ </code></pre>
88
+
89
+ <p>Or install it yourself as:</p>
90
+
91
+ <pre class="code ruby"><code class="ruby">$ gem install filestack
92
+ </code></pre>
93
+
94
+ <h2>Usage</h2>
95
+
96
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>filestack</span><span class='tstring_end'>&#39;</span></span>
97
+ </code></pre>
98
+
99
+ <p>Intialize the client using your API key, and security if you are using it. </p>
100
+
101
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_client'>client</span> <span class='op'>=</span> <span class='const'>Client</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>YOUR_API_KEY</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>security:</span> <span class='id identifier rubyid_security_object'>security_object</span><span class='rparen'>)</span>
102
+ </code></pre>
103
+
104
+ <h3>Uploading</h3>
105
+
106
+ <p>Filestack uses multipart uploading by default, which is faster for larger files. This can be turned off by passing in <code>multipart: false</code>. Multipart is disabled when uploading external URLs. </p>
107
+
108
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_filelink'>filelink</span> <span class='op'>=</span> <span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_upload'>upload</span><span class='lparen'>(</span><span class='label'>filepath:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>/path/to/file</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
109
+
110
+ <span class='comment'># OR
111
+ </span>
112
+ <span class='id identifier rubyid_filelink'>filelink</span> <span class='op'>=</span> <span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_upload'>upload</span><span class='lparen'>(</span><span class='label'>external_url:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>http://someurl.com</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
113
+ </code></pre>
114
+
115
+ <h3>Security</h3>
116
+
117
+ <p>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. </p>
118
+
119
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_security'>security</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FilestackSecurity.html" title="FilestackSecurity (class)">FilestackSecurity</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="FilestackSecurity.html#initialize-instance_method" title="FilestackSecurity#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>YOUR_APP_SECRET</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>options:</span> <span class='lbrace'>{</span><span class='label'>call:</span> <span class='qwords_beg'>%w[</span><span class='tstring_content'>read</span><span class='words_sep'> </span><span class='tstring_content'>store</span><span class='words_sep'> </span><span class='tstring_content'>pick</span><span class='words_sep'>]</span><span class='rbrace'>}</span><span class='rparen'>)</span>
120
+ <span class='id identifier rubyid_client'>client</span> <span class='op'>=</span> <span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>YOUR_API_KEY</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>security:</span> <span class='id identifier rubyid_security'>security</span><span class='rparen'>)</span>
121
+ </code></pre>
122
+
123
+ <h3>Using Filelinks</h3>
124
+
125
+ <p>Filelink objects are representation of a file handle. You can download, get raw file content, delete and overwrite file handles directly. Security is required for overwrite and delete methods. </p>
126
+
127
+ <h3>Transformations</h3>
128
+
129
+ <p>Transforms can be initiated one of two ways. The first, by calling <code>transform</code> on a filelink:</p>
130
+
131
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_transform'>transform</span> <span class='op'>=</span> <span class='id identifier rubyid_filelink'>filelink</span><span class='period'>.</span><span class='id identifier rubyid_transform'>transform</span>
132
+ </code></pre>
133
+
134
+ <p>Or by using an external URL via the client:</p>
135
+
136
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_transform'>transform</span> <span class='op'>=</span> <span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_convert_external'>convert_external</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>https://someurl.com</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
137
+ </code></pre>
138
+
139
+ <p>Transformations can be chained together as you please.</p>
140
+
141
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_transform'>transform</span> <span class='op'>=</span> <span class='id identifier rubyid_filelink'>filelink</span><span class='period'>.</span><span class='id identifier rubyid_transform'>transform</span><span class='period'>.</span><span class='id identifier rubyid_resize'>resize</span><span class='lparen'>(</span><span class='label'>width:</span> <span class='int'>100</span><span class='comma'>,</span> <span class='label'>height:</span> <span class='int'>100</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_flip'>flip</span><span class='period'>.</span><span class='id identifier rubyid_enhance'>enhance</span>
142
+ </code></pre>
143
+
144
+ <p>You can retrieve the URL of a transform object:</p>
145
+
146
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_transform'>transform</span><span class='period'>.</span><span class='id identifier rubyid_url'>url</span>
147
+ </code></pre>
148
+
149
+ <p>Or you can store (upload) the transformation as a new filelink:</p>
150
+
151
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_new_filelink'>new_filelink</span> <span class='op'>=</span> <span class='id identifier rubyid_transform'>transform</span><span class='period'>.</span><span class='id identifier rubyid_store'>store</span>
152
+ </code></pre>
153
+
154
+ <p>For a list of valid transformations, please see <a href="https://www.filestack.com/docs/image-transformations">here</a>.</p>
155
+
156
+ <h3>Tagging</h3>
157
+
158
+ <p>If you have auto-tagging enabled onto your account, it can be called on any filelink object (tags don&#39;t work on external URLs).</p>
159
+
160
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_tags'>tags</span> <span class='op'>=</span> <span class='id identifier rubyid_filelink'>filelink</span><span class='period'>.</span><span class='id identifier rubyid_tags'>tags</span>
161
+ </code></pre>
162
+
163
+ <p>This will return a hash with labels and their associated confidence:</p>
164
+
165
+ <pre class="code ruby"><code class="ruby"><span class='lbrace'>{</span>
166
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>auto</span><span class='tstring_end'>&quot;</span></span> <span class='op'>=&gt;</span> <span class='lbrace'>{</span>
167
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>art</span><span class='tstring_end'>&quot;</span></span><span class='op'>=&gt;</span><span class='int'>73</span><span class='comma'>,</span>
168
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>big cats</span><span class='tstring_end'>&quot;</span></span><span class='op'>=&gt;</span><span class='int'>79</span><span class='comma'>,</span>
169
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>carnivoran</span><span class='tstring_end'>&quot;</span></span><span class='op'>=&gt;</span><span class='int'>80</span><span class='comma'>,</span>
170
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>cartoon</span><span class='tstring_end'>&quot;</span></span><span class='op'>=&gt;</span><span class='int'>93</span><span class='comma'>,</span>
171
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>cat like mammal</span><span class='tstring_end'>&quot;</span></span><span class='op'>=&gt;</span><span class='int'>92</span><span class='comma'>,</span>
172
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>fauna</span><span class='tstring_end'>&quot;</span></span><span class='op'>=&gt;</span><span class='int'>86</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>mammal</span><span class='tstring_end'>&quot;</span></span><span class='op'>=&gt;</span><span class='int'>92</span><span class='comma'>,</span>
173
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>small to medium sized cats</span><span class='tstring_end'>&quot;</span></span><span class='op'>=&gt;</span><span class='int'>89</span><span class='comma'>,</span>
174
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>tiger</span><span class='tstring_end'>&quot;</span></span><span class='op'>=&gt;</span><span class='int'>92</span><span class='comma'>,</span>
175
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>vertebrate</span><span class='tstring_end'>&quot;</span></span><span class='op'>=&gt;</span><span class='int'>90</span><span class='rbrace'>}</span><span class='comma'>,</span>
176
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>user</span><span class='tstring_end'>&quot;</span></span> <span class='op'>=&gt;</span> <span class='kw'>nil</span>
177
+ <span class='rbrace'>}</span>
178
+ </code></pre>
179
+
180
+ <p>SFW is called the same way, but returns a boolean value (true == safe-for-work, false == not-safe-for-work). </p>
181
+
182
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_sfw'>sfw</span> <span class='op'>=</span> <span class='id identifier rubyid_filelink'>filelink</span><span class='period'>.</span><span class='id identifier rubyid_sfw'>sfw</span>
183
+ </code></pre>
184
+
185
+ <h2>Versioning</h2>
186
+
187
+ <p>Filestack Ruby SDK follows the <a href="http://semver.org/">Semantic Versioning</a>.</p>
188
+
189
+ <h2>Issues</h2>
190
+
191
+ <p>If you have problems, please create a <a href="https://github.com/filestack/filestack-ruby/issues">Github Issue</a>.</p>
192
+
193
+ <h2>Contributing</h2>
194
+
195
+ <p>Please see <a href="https://github.com/filestack/filestack-ruby/CONTRIBUTING.md">CONTRIBUTING.md</a> for details.</p>
196
+
197
+ <h2>Credits</h2>
198
+
199
+ <p>Thank you to all the <a href="https://github.com/filestack/filestack-ruby/graphs/contributors">contributors</a>.</p>
200
+ </div></div>
201
+
202
+ <div id="footer">
203
+ Generated on Thu Aug 17 10:04:38 2017 by
204
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
205
+ 0.9.9 (ruby-2.4.0).
206
+ </div>
207
+
208
+ </div>
209
+ </body>
210
+ </html>
@@ -0,0 +1,56 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
5
+ <meta charset="utf-8" />
6
+
7
+ <link rel="stylesheet" href="css/full_list.css" type="text/css" media="screen" charset="utf-8" />
8
+
9
+ <link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
10
+
11
+
12
+
13
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
14
+
15
+ <script type="text/javascript" charset="utf-8" src="js/full_list.js"></script>
16
+
17
+
18
+ <title>File List</title>
19
+ <base id="base_target" target="_parent" />
20
+ </head>
21
+ <body>
22
+ <div id="content">
23
+ <div class="fixed_header">
24
+ <h1 id="full_list_header">File List</h1>
25
+ <div id="full_list_nav">
26
+
27
+ <span><a target="_self" href="class_list.html">
28
+ Classes
29
+ </a></span>
30
+
31
+ <span><a target="_self" href="method_list.html">
32
+ Methods
33
+ </a></span>
34
+
35
+ <span><a target="_self" href="file_list.html">
36
+ Files
37
+ </a></span>
38
+
39
+ </div>
40
+
41
+ <div id="search">Search: <input type="text" /></div>
42
+ </div>
43
+
44
+ <ul id="full_list" class="file">
45
+
46
+
47
+ <li id="object_README" class="odd">
48
+ <div class="item"><span class="object_link"><a href="index.html" title="README">README</a></span></div>
49
+ </li>
50
+
51
+
52
+
53
+ </ul>
54
+ </div>
55
+ </body>
56
+ </html>
@@ -0,0 +1,17 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>Documentation by YARD 0.9.9</title>
6
+ </head>
7
+ <script type="text/javascript" charset="utf-8">
8
+ var match = unescape(window.location.hash).match(/^#!(.+)/);
9
+ var name = match ? match[1] : 'index.html';
10
+ name = name.replace(/^(\w+):\/\//, '').replace(/^\/\//, '');
11
+ window.top.location = name;
12
+ </script>
13
+ <noscript>
14
+ <h1>Oops!</h1>
15
+ <h2>YARD requires JavaScript!</h2>
16
+ </noscript>
17
+ </html>
@@ -0,0 +1,210 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ File: README
8
+
9
+ &mdash; Documentation by YARD 0.9.9
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ pathId = "README";
19
+ relpath = '';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="_index.html">Index</a> &raquo;
40
+ <span class="title">File: README</span>
41
+
42
+ </div>
43
+
44
+ <div id="search">
45
+
46
+ <a class="full_list_link" id="class_list_link"
47
+ href="class_list.html">
48
+
49
+ <svg width="24" height="24">
50
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
51
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
52
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
53
+ </svg>
54
+ </a>
55
+
56
+ </div>
57
+ <div class="clear"></div>
58
+ </div>
59
+
60
+ <div id="content"><div id='filecontents'><p><a href="http://travis-ci.org/filestack/filestack-ruby"><img src="https://travis-ci.org/filestack/filestack-ruby.svg?branch=master%09%09" alt="Travis CI"></a>
61
+ <a href="https://coveralls.io/github/filestack/filestack-ruby?branch=master%09%09"><img src="https://coveralls.io/repos/github/filestack/filestack-ruby/badge.svg?branch=master" alt="Coveralls"></a>
62
+ <a href="https://codeclimate.com/github/filestack/filestack-ruby%09%09"><img src="https://codeclimate.com/github/filestack/filestack-ruby.png%09%09" alt="Code Climate"></a></p>
63
+
64
+ <h1>Filestack Ruby SDK</h1>
65
+
66
+ <p><a href="https://www.filestack.com"><img src="https://filestack.com/themes/filestack/assets/images/press-articles/color.svg" align="left" hspace="10" vspace="6"></a>
67
+ This is the official Ruby SDK for Filestack - API and content management system that makes it easy to add powerful file uploading and transformation capabilities to any web or mobile application.</p>
68
+
69
+ <h2>Resources</h2>
70
+
71
+ <ul>
72
+ <li><a href="https://www.filestack.com">Filestack</a></li>
73
+ <li><a href="https://www.filestack.com/docs">Documentation</a></li>
74
+ <li><a href="https://filestack.github.io/">API Reference</a></li>
75
+ </ul>
76
+
77
+ <h2>Installing</h2>
78
+
79
+ <p>Add this line to your application&#39;s Gemfile:</p>
80
+
81
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_gem'>gem</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>filestack</span><span class='tstring_end'>&#39;</span></span>
82
+ </code></pre>
83
+
84
+ <p>And then execute:</p>
85
+
86
+ <pre class="code ruby"><code class="ruby">$ bundle
87
+ </code></pre>
88
+
89
+ <p>Or install it yourself as:</p>
90
+
91
+ <pre class="code ruby"><code class="ruby">$ gem install filestack
92
+ </code></pre>
93
+
94
+ <h2>Usage</h2>
95
+
96
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>filestack</span><span class='tstring_end'>&#39;</span></span>
97
+ </code></pre>
98
+
99
+ <p>Intialize the client using your API key, and security if you are using it. </p>
100
+
101
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_client'>client</span> <span class='op'>=</span> <span class='const'>Client</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>YOUR_API_KEY</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>security:</span> <span class='id identifier rubyid_security_object'>security_object</span><span class='rparen'>)</span>
102
+ </code></pre>
103
+
104
+ <h3>Uploading</h3>
105
+
106
+ <p>Filestack uses multipart uploading by default, which is faster for larger files. This can be turned off by passing in <code>multipart: false</code>. Multipart is disabled when uploading external URLs. </p>
107
+
108
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_filelink'>filelink</span> <span class='op'>=</span> <span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_upload'>upload</span><span class='lparen'>(</span><span class='label'>filepath:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>/path/to/file</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
109
+
110
+ <span class='comment'># OR
111
+ </span>
112
+ <span class='id identifier rubyid_filelink'>filelink</span> <span class='op'>=</span> <span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_upload'>upload</span><span class='lparen'>(</span><span class='label'>external_url:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>http://someurl.com</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
113
+ </code></pre>
114
+
115
+ <h3>Security</h3>
116
+
117
+ <p>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. </p>
118
+
119
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_security'>security</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FilestackSecurity.html" title="FilestackSecurity (class)">FilestackSecurity</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="FilestackSecurity.html#initialize-instance_method" title="FilestackSecurity#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>YOUR_APP_SECRET</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>options:</span> <span class='lbrace'>{</span><span class='label'>call:</span> <span class='qwords_beg'>%w[</span><span class='tstring_content'>read</span><span class='words_sep'> </span><span class='tstring_content'>store</span><span class='words_sep'> </span><span class='tstring_content'>pick</span><span class='words_sep'>]</span><span class='rbrace'>}</span><span class='rparen'>)</span>
120
+ <span class='id identifier rubyid_client'>client</span> <span class='op'>=</span> <span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>YOUR_API_KEY</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>security:</span> <span class='id identifier rubyid_security'>security</span><span class='rparen'>)</span>
121
+ </code></pre>
122
+
123
+ <h3>Using Filelinks</h3>
124
+
125
+ <p>Filelink objects are representation of a file handle. You can download, get raw file content, delete and overwrite file handles directly. Security is required for overwrite and delete methods. </p>
126
+
127
+ <h3>Transformations</h3>
128
+
129
+ <p>Transforms can be initiated one of two ways. The first, by calling <code>transform</code> on a filelink:</p>
130
+
131
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_transform'>transform</span> <span class='op'>=</span> <span class='id identifier rubyid_filelink'>filelink</span><span class='period'>.</span><span class='id identifier rubyid_transform'>transform</span>
132
+ </code></pre>
133
+
134
+ <p>Or by using an external URL via the client:</p>
135
+
136
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_transform'>transform</span> <span class='op'>=</span> <span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_convert_external'>convert_external</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>https://someurl.com</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
137
+ </code></pre>
138
+
139
+ <p>Transformations can be chained together as you please.</p>
140
+
141
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_transform'>transform</span> <span class='op'>=</span> <span class='id identifier rubyid_filelink'>filelink</span><span class='period'>.</span><span class='id identifier rubyid_transform'>transform</span><span class='period'>.</span><span class='id identifier rubyid_resize'>resize</span><span class='lparen'>(</span><span class='label'>width:</span> <span class='int'>100</span><span class='comma'>,</span> <span class='label'>height:</span> <span class='int'>100</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_flip'>flip</span><span class='period'>.</span><span class='id identifier rubyid_enhance'>enhance</span>
142
+ </code></pre>
143
+
144
+ <p>You can retrieve the URL of a transform object:</p>
145
+
146
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_transform'>transform</span><span class='period'>.</span><span class='id identifier rubyid_url'>url</span>
147
+ </code></pre>
148
+
149
+ <p>Or you can store (upload) the transformation as a new filelink:</p>
150
+
151
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_new_filelink'>new_filelink</span> <span class='op'>=</span> <span class='id identifier rubyid_transform'>transform</span><span class='period'>.</span><span class='id identifier rubyid_store'>store</span>
152
+ </code></pre>
153
+
154
+ <p>For a list of valid transformations, please see <a href="https://www.filestack.com/docs/image-transformations">here</a>.</p>
155
+
156
+ <h3>Tagging</h3>
157
+
158
+ <p>If you have auto-tagging enabled onto your account, it can be called on any filelink object (tags don&#39;t work on external URLs).</p>
159
+
160
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_tags'>tags</span> <span class='op'>=</span> <span class='id identifier rubyid_filelink'>filelink</span><span class='period'>.</span><span class='id identifier rubyid_tags'>tags</span>
161
+ </code></pre>
162
+
163
+ <p>This will return a hash with labels and their associated confidence:</p>
164
+
165
+ <pre class="code ruby"><code class="ruby"><span class='lbrace'>{</span>
166
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>auto</span><span class='tstring_end'>&quot;</span></span> <span class='op'>=&gt;</span> <span class='lbrace'>{</span>
167
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>art</span><span class='tstring_end'>&quot;</span></span><span class='op'>=&gt;</span><span class='int'>73</span><span class='comma'>,</span>
168
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>big cats</span><span class='tstring_end'>&quot;</span></span><span class='op'>=&gt;</span><span class='int'>79</span><span class='comma'>,</span>
169
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>carnivoran</span><span class='tstring_end'>&quot;</span></span><span class='op'>=&gt;</span><span class='int'>80</span><span class='comma'>,</span>
170
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>cartoon</span><span class='tstring_end'>&quot;</span></span><span class='op'>=&gt;</span><span class='int'>93</span><span class='comma'>,</span>
171
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>cat like mammal</span><span class='tstring_end'>&quot;</span></span><span class='op'>=&gt;</span><span class='int'>92</span><span class='comma'>,</span>
172
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>fauna</span><span class='tstring_end'>&quot;</span></span><span class='op'>=&gt;</span><span class='int'>86</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>mammal</span><span class='tstring_end'>&quot;</span></span><span class='op'>=&gt;</span><span class='int'>92</span><span class='comma'>,</span>
173
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>small to medium sized cats</span><span class='tstring_end'>&quot;</span></span><span class='op'>=&gt;</span><span class='int'>89</span><span class='comma'>,</span>
174
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>tiger</span><span class='tstring_end'>&quot;</span></span><span class='op'>=&gt;</span><span class='int'>92</span><span class='comma'>,</span>
175
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>vertebrate</span><span class='tstring_end'>&quot;</span></span><span class='op'>=&gt;</span><span class='int'>90</span><span class='rbrace'>}</span><span class='comma'>,</span>
176
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>user</span><span class='tstring_end'>&quot;</span></span> <span class='op'>=&gt;</span> <span class='kw'>nil</span>
177
+ <span class='rbrace'>}</span>
178
+ </code></pre>
179
+
180
+ <p>SFW is called the same way, but returns a boolean value (true == safe-for-work, false == not-safe-for-work). </p>
181
+
182
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_sfw'>sfw</span> <span class='op'>=</span> <span class='id identifier rubyid_filelink'>filelink</span><span class='period'>.</span><span class='id identifier rubyid_sfw'>sfw</span>
183
+ </code></pre>
184
+
185
+ <h2>Versioning</h2>
186
+
187
+ <p>Filestack Ruby SDK follows the <a href="http://semver.org/">Semantic Versioning</a>.</p>
188
+
189
+ <h2>Issues</h2>
190
+
191
+ <p>If you have problems, please create a <a href="https://github.com/filestack/filestack-ruby/issues">Github Issue</a>.</p>
192
+
193
+ <h2>Contributing</h2>
194
+
195
+ <p>Please see <a href="https://github.com/filestack/filestack-ruby/CONTRIBUTING.md">CONTRIBUTING.md</a> for details.</p>
196
+
197
+ <h2>Credits</h2>
198
+
199
+ <p>Thank you to all the <a href="https://github.com/filestack/filestack-ruby/graphs/contributors">contributors</a>.</p>
200
+ </div></div>
201
+
202
+ <div id="footer">
203
+ Generated on Thu Aug 17 10:04:38 2017 by
204
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
205
+ 0.9.9 (ruby-2.4.0).
206
+ </div>
207
+
208
+ </div>
209
+ </body>
210
+ </html>