filestack 2.1.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
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,1639 @@
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
+ Module: IntelligentUtils
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 = "IntelligentUtils";
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 (I)</a> &raquo;
40
+
41
+
42
+ <span class="title">IntelligentUtils</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <div id="content"><h1>Module: IntelligentUtils
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+ <dl>
80
+ <dt>Defined in:</dt>
81
+ <dd>lib/filestack/utils/utils.rb</dd>
82
+ </dl>
83
+
84
+ </div>
85
+
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+ <h2>
95
+ Instance Method Summary
96
+ <small><a href="#" class="summary_toggle">collapse</a></small>
97
+ </h2>
98
+
99
+ <ul class="summary">
100
+
101
+ <li class="public ">
102
+ <span class="summary_signature">
103
+
104
+ <a href="#bad_state-instance_method" title="#bad_state (instance method)">#<strong>bad_state</strong>(state) &#x21d2; Boolean </a>
105
+
106
+
107
+
108
+ </span>
109
+
110
+
111
+
112
+
113
+
114
+
115
+
116
+
117
+
118
+ <span class="summary_desc"><div class='inline'>
119
+ <p>Check if state is in error state or has reached maximum retries.</p>
120
+ </div></span>
121
+
122
+ </li>
123
+
124
+
125
+ <li class="public ">
126
+ <span class="summary_signature">
127
+
128
+ <a href="#change_offset-instance_method" title="#change_offset (instance method)">#<strong>change_offset</strong>(working_offset, state) &#x21d2; Integer </a>
129
+
130
+
131
+
132
+ </span>
133
+
134
+
135
+
136
+
137
+
138
+
139
+
140
+
141
+
142
+ <span class="summary_desc"><div class='inline'>
143
+ <p>Return current working offest if state has not tried it.</p>
144
+ </div></span>
145
+
146
+ </li>
147
+
148
+
149
+ <li class="public ">
150
+ <span class="summary_signature">
151
+
152
+ <a href="#chunk_job-instance_method" title="#chunk_job (instance method)">#<strong>chunk_job</strong>(job, state, apikey, filename, filepath, filesize, start_response) &#x21d2; Dict </a>
153
+
154
+
155
+
156
+ </span>
157
+
158
+
159
+
160
+
161
+
162
+
163
+
164
+
165
+
166
+ <span class="summary_desc"><div class='inline'>
167
+ <p>Chunk a specific job into offests.</p>
168
+ </div></span>
169
+
170
+ </li>
171
+
172
+
173
+ <li class="public ">
174
+ <span class="summary_signature">
175
+
176
+ <a href="#create_intelligent_generator-instance_method" title="#create_intelligent_generator (instance method)">#<strong>create_intelligent_generator</strong>(jobs) &#x21d2; Fiber </a>
177
+
178
+
179
+
180
+ </span>
181
+
182
+
183
+
184
+
185
+
186
+
187
+
188
+
189
+
190
+ <span class="summary_desc"><div class='inline'>
191
+ <p>Creates a generator of part jobs.</p>
192
+ </div></span>
193
+
194
+ </li>
195
+
196
+
197
+ <li class="public ">
198
+ <span class="summary_signature">
199
+
200
+ <a href="#create_upload_job_chunks-instance_method" title="#create_upload_job_chunks (instance method)">#<strong>create_upload_job_chunks</strong>(jobs, state, apikey, filename, filepath, filesize, start_response) &#x21d2; Array </a>
201
+
202
+
203
+
204
+ </span>
205
+
206
+
207
+
208
+
209
+
210
+
211
+
212
+
213
+
214
+ <span class="summary_desc"><div class='inline'>
215
+ <p>Loop and run chunks for each offset.</p>
216
+ </div></span>
217
+
218
+ </li>
219
+
220
+
221
+ <li class="public ">
222
+ <span class="summary_signature">
223
+
224
+ <a href="#get_generator_batch-instance_method" title="#get_generator_batch (instance method)">#<strong>get_generator_batch</strong>(generator) &#x21d2; Array </a>
225
+
226
+
227
+
228
+ </span>
229
+
230
+
231
+
232
+
233
+
234
+
235
+
236
+
237
+
238
+ <span class="summary_desc"><div class='inline'>
239
+ <p>Generates a batch given a Fiber.</p>
240
+ </div></span>
241
+
242
+ </li>
243
+
244
+
245
+ <li class="public ">
246
+ <span class="summary_signature">
247
+
248
+ <a href="#run_intelligent_upload_flow-instance_method" title="#run_intelligent_upload_flow (instance method)">#<strong>run_intelligent_upload_flow</strong>(jobs, state) &#x21d2; Array </a>
249
+
250
+
251
+
252
+ </span>
253
+
254
+
255
+
256
+
257
+
258
+
259
+
260
+
261
+
262
+ <span class="summary_desc"><div class='inline'>
263
+ <p>Runs the intelligent upload flow, from start to finish.</p>
264
+ </div></span>
265
+
266
+ </li>
267
+
268
+
269
+ <li class="public ">
270
+ <span class="summary_signature">
271
+
272
+ <a href="#run_intelligent_uploads-instance_method" title="#run_intelligent_uploads (instance method)">#<strong>run_intelligent_uploads</strong>(part, state) &#x21d2; IntelligentState </a>
273
+
274
+
275
+
276
+ </span>
277
+
278
+
279
+
280
+
281
+
282
+
283
+
284
+
285
+
286
+ <span class="summary_desc"><div class='inline'>
287
+ <p>Send a job&#39;s chunks in parallel and commit.</p>
288
+ </div></span>
289
+
290
+ </li>
291
+
292
+
293
+ <li class="public ">
294
+ <span class="summary_signature">
295
+
296
+ <a href="#upload_chunk_intelligently-instance_method" title="#upload_chunk_intelligently (instance method)">#<strong>upload_chunk_intelligently</strong>(job, state, apikey, filepath, options) &#x21d2; Unirest::Response </a>
297
+
298
+
299
+
300
+ </span>
301
+
302
+
303
+
304
+
305
+
306
+
307
+
308
+
309
+
310
+ <span class="summary_desc"><div class='inline'>
311
+ <p>Upload a single chunk.</p>
312
+ </div></span>
313
+
314
+ </li>
315
+
316
+
317
+ </ul>
318
+
319
+
320
+
321
+
322
+ <div id="instance_method_details" class="method_details_list">
323
+ <h2>Instance Method Details</h2>
324
+
325
+
326
+ <div class="method_details first">
327
+ <h3 class="signature first" id="bad_state-instance_method">
328
+
329
+ #<strong>bad_state</strong>(state) &#x21d2; <tt>Boolean</tt>
330
+
331
+
332
+
333
+
334
+
335
+ </h3><div class="docstring">
336
+ <div class="discussion">
337
+
338
+ <p>Check if state is in error state or has reached maximum retries</p>
339
+
340
+
341
+ </div>
342
+ </div>
343
+ <div class="tags">
344
+ <p class="tag_title">Parameters:</p>
345
+ <ul class="param">
346
+
347
+ <li>
348
+
349
+ <span class='name'>state</span>
350
+
351
+
352
+ <span class='type'>(<tt><span class='object_link'><a href="IntelligentState.html" title="IntelligentState (class)">IntelligentState</a></span></tt>)</span>
353
+
354
+
355
+
356
+ &mdash;
357
+ <div class='inline'>
358
+ <p>An IntelligentState object</p>
359
+ </div>
360
+
361
+ </li>
362
+
363
+ </ul>
364
+
365
+ <p class="tag_title">Returns:</p>
366
+ <ul class="return">
367
+
368
+ <li>
369
+
370
+
371
+ <span class='type'>(<tt>Boolean</tt>)</span>
372
+
373
+
374
+
375
+ </li>
376
+
377
+ </ul>
378
+
379
+ </div><table class="source_code">
380
+ <tr>
381
+ <td>
382
+ <pre class="lines">
383
+
384
+
385
+ 170
386
+ 171
387
+ 172</pre>
388
+ </td>
389
+ <td>
390
+ <pre class="code"><span class="info file"># File 'lib/filestack/utils/utils.rb', line 170</span>
391
+
392
+ <span class='kw'>def</span> <span class='id identifier rubyid_bad_state'>bad_state</span><span class='lparen'>(</span><span class='id identifier rubyid_state'>state</span><span class='rparen'>)</span>
393
+ <span class='op'>!</span><span class='id identifier rubyid_state'>state</span><span class='period'>.</span><span class='id identifier rubyid_ok'>ok</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_state'>state</span><span class='period'>.</span><span class='id identifier rubyid_alive?'>alive?</span>
394
+ <span class='kw'>end</span></pre>
395
+ </td>
396
+ </tr>
397
+ </table>
398
+ </div>
399
+
400
+ <div class="method_details ">
401
+ <h3 class="signature " id="change_offset-instance_method">
402
+
403
+ #<strong>change_offset</strong>(working_offset, state) &#x21d2; <tt>Integer</tt>
404
+
405
+
406
+
407
+
408
+
409
+ </h3><div class="docstring">
410
+ <div class="discussion">
411
+
412
+ <p>Return current working offest if state has not tried it. Otherwise, return
413
+ the next offset of the state</p>
414
+
415
+
416
+ </div>
417
+ </div>
418
+ <div class="tags">
419
+ <p class="tag_title">Parameters:</p>
420
+ <ul class="param">
421
+
422
+ <li>
423
+
424
+ <span class='name'>working_offset</span>
425
+
426
+
427
+ <span class='type'>(<tt>Integer</tt>)</span>
428
+
429
+
430
+
431
+ &mdash;
432
+ <div class='inline'>
433
+ <p>The current offset</p>
434
+ </div>
435
+
436
+ </li>
437
+
438
+ <li>
439
+
440
+ <span class='name'>state</span>
441
+
442
+
443
+ <span class='type'>(<tt><span class='object_link'><a href="IntelligentState.html" title="IntelligentState (class)">IntelligentState</a></span></tt>)</span>
444
+
445
+
446
+
447
+ &mdash;
448
+ <div class='inline'>
449
+ <p>An IntelligentState object</p>
450
+ </div>
451
+
452
+ </li>
453
+
454
+ </ul>
455
+
456
+ <p class="tag_title">Returns:</p>
457
+ <ul class="return">
458
+
459
+ <li>
460
+
461
+
462
+ <span class='type'>(<tt>Integer</tt>)</span>
463
+
464
+
465
+
466
+ </li>
467
+
468
+ </ul>
469
+
470
+ </div><table class="source_code">
471
+ <tr>
472
+ <td>
473
+ <pre class="lines">
474
+
475
+
476
+ 182
477
+ 183
478
+ 184
479
+ 185
480
+ 186
481
+ 187
482
+ 188</pre>
483
+ </td>
484
+ <td>
485
+ <pre class="code"><span class="info file"># File 'lib/filestack/utils/utils.rb', line 182</span>
486
+
487
+ <span class='kw'>def</span> <span class='id identifier rubyid_change_offset'>change_offset</span><span class='lparen'>(</span><span class='id identifier rubyid_working_offset'>working_offset</span><span class='comma'>,</span> <span class='id identifier rubyid_state'>state</span><span class='rparen'>)</span>
488
+ <span class='kw'>if</span> <span class='id identifier rubyid_state'>state</span><span class='period'>.</span><span class='id identifier rubyid_offset'>offset</span> <span class='op'>&gt;</span> <span class='id identifier rubyid_working_offset'>working_offset</span>
489
+ <span class='id identifier rubyid_working_offset'>working_offset</span>
490
+ <span class='kw'>else</span>
491
+ <span class='id identifier rubyid_state'>state</span><span class='period'>.</span><span class='id identifier rubyid_offset'>offset</span> <span class='op'>=</span> <span class='id identifier rubyid_state'>state</span><span class='period'>.</span><span class='id identifier rubyid_next_offset'>next_offset</span>
492
+ <span class='kw'>end</span>
493
+ <span class='kw'>end</span></pre>
494
+ </td>
495
+ </tr>
496
+ </table>
497
+ </div>
498
+
499
+ <div class="method_details ">
500
+ <h3 class="signature " id="chunk_job-instance_method">
501
+
502
+ #<strong>chunk_job</strong>(job, state, apikey, filename, filepath, filesize, start_response) &#x21d2; <tt>Dict</tt>
503
+
504
+
505
+
506
+
507
+
508
+ </h3><div class="docstring">
509
+ <div class="discussion">
510
+
511
+ <p>Chunk a specific job into offests</p>
512
+
513
+
514
+ </div>
515
+ </div>
516
+ <div class="tags">
517
+ <p class="tag_title">Parameters:</p>
518
+ <ul class="param">
519
+
520
+ <li>
521
+
522
+ <span class='name'>job</span>
523
+
524
+
525
+ <span class='type'>(<tt>Dict</tt>)</span>
526
+
527
+
528
+
529
+ &mdash;
530
+ <div class='inline'>
531
+ <p>Dictionary with all job options</p>
532
+ </div>
533
+
534
+ </li>
535
+
536
+ <li>
537
+
538
+ <span class='name'>state</span>
539
+
540
+
541
+ <span class='type'>(<tt><span class='object_link'><a href="IntelligentState.html" title="IntelligentState (class)">IntelligentState</a></span></tt>)</span>
542
+
543
+
544
+
545
+ &mdash;
546
+ <div class='inline'>
547
+ <p>An IntelligentState object</p>
548
+ </div>
549
+
550
+ </li>
551
+
552
+ <li>
553
+
554
+ <span class='name'>apikey</span>
555
+
556
+
557
+ <span class='type'>(<tt>String</tt>)</span>
558
+
559
+
560
+
561
+ &mdash;
562
+ <div class='inline'>
563
+ <p>Filestack API key</p>
564
+ </div>
565
+
566
+ </li>
567
+
568
+ <li>
569
+
570
+ <span class='name'>filename</span>
571
+
572
+
573
+ <span class='type'>(<tt>String</tt>)</span>
574
+
575
+
576
+
577
+ &mdash;
578
+ <div class='inline'>
579
+ <p>Name of incoming file</p>
580
+ </div>
581
+
582
+ </li>
583
+
584
+ <li>
585
+
586
+ <span class='name'>filepath</span>
587
+
588
+
589
+ <span class='type'>(<tt>String</tt>)</span>
590
+
591
+
592
+
593
+ &mdash;
594
+ <div class='inline'>
595
+ <p>Local path to the file</p>
596
+ </div>
597
+
598
+ </li>
599
+
600
+ <li>
601
+
602
+ <span class='name'>filesize</span>
603
+
604
+
605
+ <span class='type'>(<tt>Int</tt>)</span>
606
+
607
+
608
+
609
+ &mdash;
610
+ <div class='inline'>
611
+ <p>Size of incoming file</p>
612
+ </div>
613
+
614
+ </li>
615
+
616
+ <li>
617
+
618
+ <span class='name'>start_response</span>
619
+
620
+
621
+ <span class='type'>(<tt>Unirest::Response</tt>)</span>
622
+
623
+
624
+
625
+ &mdash;
626
+ <div class='inline'>
627
+ <p>Response body from multipart_start</p>
628
+ </div>
629
+
630
+ </li>
631
+
632
+ </ul>
633
+
634
+ <p class="tag_title">Returns:</p>
635
+ <ul class="return">
636
+
637
+ <li>
638
+
639
+
640
+ <span class='type'>(<tt>Dict</tt>)</span>
641
+
642
+
643
+
644
+ </li>
645
+
646
+ </ul>
647
+
648
+ </div><table class="source_code">
649
+ <tr>
650
+ <td>
651
+ <pre class="lines">
652
+
653
+
654
+ 272
655
+ 273
656
+ 274
657
+ 275
658
+ 276
659
+ 277
660
+ 278
661
+ 279
662
+ 280
663
+ 281
664
+ 282
665
+ 283
666
+ 284
667
+ 285
668
+ 286
669
+ 287
670
+ 288
671
+ 289
672
+ 290
673
+ 291
674
+ 292
675
+ 293
676
+ 294</pre>
677
+ </td>
678
+ <td>
679
+ <pre class="code"><span class="info file"># File 'lib/filestack/utils/utils.rb', line 272</span>
680
+
681
+ <span class='kw'>def</span> <span class='id identifier rubyid_chunk_job'>chunk_job</span><span class='lparen'>(</span><span class='id identifier rubyid_job'>job</span><span class='comma'>,</span> <span class='id identifier rubyid_state'>state</span><span class='comma'>,</span> <span class='id identifier rubyid_apikey'>apikey</span><span class='comma'>,</span> <span class='id identifier rubyid_filename'>filename</span><span class='comma'>,</span> <span class='id identifier rubyid_filepath'>filepath</span><span class='comma'>,</span> <span class='id identifier rubyid_filesize'>filesize</span><span class='comma'>,</span> <span class='id identifier rubyid_start_response'>start_response</span><span class='rparen'>)</span>
682
+ <span class='id identifier rubyid_offset'>offset</span> <span class='op'>=</span> <span class='int'>0</span>
683
+ <span class='id identifier rubyid_seek_point'>seek_point</span> <span class='op'>=</span> <span class='id identifier rubyid_job'>job</span><span class='lbracket'>[</span><span class='symbol'>:seek</span><span class='rbracket'>]</span>
684
+ <span class='id identifier rubyid_chunk_list'>chunk_list</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
685
+ <span class='kw'>while</span> <span class='lparen'>(</span><span class='id identifier rubyid_offset'>offset</span> <span class='op'>&lt;</span> <span class='const'><span class='object_link'><a href="FilestackConfig.html" title="FilestackConfig (class)">FilestackConfig</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FilestackConfig.html#DEFAULT_CHUNK_SIZE-constant" title="FilestackConfig::DEFAULT_CHUNK_SIZE (constant)">DEFAULT_CHUNK_SIZE</a></span></span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='lparen'>(</span><span class='id identifier rubyid_seek_point'>seek_point</span> <span class='op'>+</span> <span class='id identifier rubyid_offset'>offset</span><span class='rparen'>)</span> <span class='op'>&lt;</span> <span class='id identifier rubyid_filesize'>filesize</span>
686
+ <span class='id identifier rubyid_chunk_list'>chunk_list</span><span class='period'>.</span><span class='id identifier rubyid_push'>push</span><span class='lparen'>(</span>
687
+ <span class='label'>seek:</span> <span class='id identifier rubyid_seek_point'>seek_point</span><span class='comma'>,</span>
688
+ <span class='label'>filepath:</span> <span class='id identifier rubyid_filepath'>filepath</span><span class='comma'>,</span>
689
+ <span class='label'>filename:</span> <span class='id identifier rubyid_filename'>filename</span><span class='comma'>,</span>
690
+ <span class='label'>apikey:</span> <span class='id identifier rubyid_apikey'>apikey</span><span class='comma'>,</span>
691
+ <span class='label'>part:</span> <span class='id identifier rubyid_job'>job</span><span class='lbracket'>[</span><span class='symbol'>:part</span><span class='rbracket'>]</span><span class='comma'>,</span>
692
+ <span class='label'>size:</span> <span class='id identifier rubyid_job'>job</span><span class='lbracket'>[</span><span class='symbol'>:size</span><span class='rbracket'>]</span><span class='comma'>,</span>
693
+ <span class='label'>uri:</span> <span class='id identifier rubyid_start_response'>start_response</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>uri</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='comma'>,</span>
694
+ <span class='label'>region:</span> <span class='id identifier rubyid_start_response'>start_response</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>region</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='comma'>,</span>
695
+ <span class='label'>upload_id:</span> <span class='id identifier rubyid_start_response'>start_response</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>upload_id</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='comma'>,</span>
696
+ <span class='label'>location_url:</span> <span class='id identifier rubyid_start_response'>start_response</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>location_url</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='comma'>,</span>
697
+ <span class='label'>store_location:</span> <span class='id identifier rubyid_job'>job</span><span class='lbracket'>[</span><span class='symbol'>:store_location</span><span class='rbracket'>]</span><span class='comma'>,</span>
698
+ <span class='label'>offset:</span> <span class='id identifier rubyid_offset'>offset</span>
699
+ <span class='rparen'>)</span>
700
+ <span class='id identifier rubyid_offset'>offset</span> <span class='op'>+=</span> <span class='id identifier rubyid_state'>state</span><span class='period'>.</span><span class='id identifier rubyid_offset'>offset</span>
701
+ <span class='kw'>end</span>
702
+ <span class='id identifier rubyid_chunk_list'>chunk_list</span>
703
+ <span class='kw'>end</span></pre>
704
+ </td>
705
+ </tr>
706
+ </table>
707
+ </div>
708
+
709
+ <div class="method_details ">
710
+ <h3 class="signature " id="create_intelligent_generator-instance_method">
711
+
712
+ #<strong>create_intelligent_generator</strong>(jobs) &#x21d2; <tt>Fiber</tt>
713
+
714
+
715
+
716
+
717
+
718
+ </h3><div class="docstring">
719
+ <div class="discussion">
720
+
721
+ <p>Creates a generator of part jobs</p>
722
+
723
+
724
+ </div>
725
+ </div>
726
+ <div class="tags">
727
+ <p class="tag_title">Parameters:</p>
728
+ <ul class="param">
729
+
730
+ <li>
731
+
732
+ <span class='name'>jobs</span>
733
+
734
+
735
+ <span class='type'>(<tt>Array</tt>)</span>
736
+
737
+
738
+
739
+ &mdash;
740
+ <div class='inline'>
741
+ <p>A list of file parts</p>
742
+ </div>
743
+
744
+ </li>
745
+
746
+ </ul>
747
+
748
+ <p class="tag_title">Returns:</p>
749
+ <ul class="return">
750
+
751
+ <li>
752
+
753
+
754
+ <span class='type'>(<tt>Fiber</tt>)</span>
755
+
756
+
757
+
758
+ </li>
759
+
760
+ </ul>
761
+
762
+ </div><table class="source_code">
763
+ <tr>
764
+ <td>
765
+ <pre class="lines">
766
+
767
+
768
+ 229
769
+ 230
770
+ 231
771
+ 232
772
+ 233
773
+ 234
774
+ 235
775
+ 236
776
+ 237</pre>
777
+ </td>
778
+ <td>
779
+ <pre class="code"><span class="info file"># File 'lib/filestack/utils/utils.rb', line 229</span>
780
+
781
+ <span class='kw'>def</span> <span class='id identifier rubyid_create_intelligent_generator'>create_intelligent_generator</span><span class='lparen'>(</span><span class='id identifier rubyid_jobs'>jobs</span><span class='rparen'>)</span>
782
+ <span class='id identifier rubyid_jobs_gen'>jobs_gen</span> <span class='op'>=</span> <span class='id identifier rubyid_jobs'>jobs</span><span class='period'>.</span><span class='id identifier rubyid_lazy'>lazy</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span>
783
+ <span class='const'>Fiber</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='kw'>do</span>
784
+ <span class='lparen'>(</span><span class='id identifier rubyid_jobs'>jobs</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span><span class='op'>-</span><span class='int'>1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_times'>times</span> <span class='kw'>do</span>
785
+ <span class='const'>Fiber</span><span class='period'>.</span><span class='id identifier rubyid_yield'>yield</span> <span class='id identifier rubyid_jobs_gen'>jobs_gen</span><span class='period'>.</span><span class='id identifier rubyid_next'>next</span>
786
+ <span class='kw'>end</span>
787
+ <span class='id identifier rubyid_jobs_gen'>jobs_gen</span><span class='period'>.</span><span class='id identifier rubyid_next'>next</span>
788
+ <span class='kw'>end</span>
789
+ <span class='kw'>end</span></pre>
790
+ </td>
791
+ </tr>
792
+ </table>
793
+ </div>
794
+
795
+ <div class="method_details ">
796
+ <h3 class="signature " id="create_upload_job_chunks-instance_method">
797
+
798
+ #<strong>create_upload_job_chunks</strong>(jobs, state, apikey, filename, filepath, filesize, start_response) &#x21d2; <tt>Array</tt>
799
+
800
+
801
+
802
+
803
+
804
+ </h3><div class="docstring">
805
+ <div class="discussion">
806
+
807
+ <p>Loop and run chunks for each offset</p>
808
+
809
+
810
+ </div>
811
+ </div>
812
+ <div class="tags">
813
+ <p class="tag_title">Parameters:</p>
814
+ <ul class="param">
815
+
816
+ <li>
817
+
818
+ <span class='name'>jobs</span>
819
+
820
+
821
+ <span class='type'>(<tt>Array</tt>)</span>
822
+
823
+
824
+
825
+ &mdash;
826
+ <div class='inline'>
827
+ <p>A list of file parts</p>
828
+ </div>
829
+
830
+ </li>
831
+
832
+ <li>
833
+
834
+ <span class='name'>state</span>
835
+
836
+
837
+ <span class='type'>(<tt><span class='object_link'><a href="IntelligentState.html" title="IntelligentState (class)">IntelligentState</a></span></tt>)</span>
838
+
839
+
840
+
841
+ &mdash;
842
+ <div class='inline'>
843
+ <p>An IntelligentState object</p>
844
+ </div>
845
+
846
+ </li>
847
+
848
+ <li>
849
+
850
+ <span class='name'>apikey</span>
851
+
852
+
853
+ <span class='type'>(<tt>String</tt>)</span>
854
+
855
+
856
+
857
+ &mdash;
858
+ <div class='inline'>
859
+ <p>Filestack API key</p>
860
+ </div>
861
+
862
+ </li>
863
+
864
+ <li>
865
+
866
+ <span class='name'>filename</span>
867
+
868
+
869
+ <span class='type'>(<tt>String</tt>)</span>
870
+
871
+
872
+
873
+ &mdash;
874
+ <div class='inline'>
875
+ <p>Name of incoming file</p>
876
+ </div>
877
+
878
+ </li>
879
+
880
+ <li>
881
+
882
+ <span class='name'>filepath</span>
883
+
884
+
885
+ <span class='type'>(<tt>String</tt>)</span>
886
+
887
+
888
+
889
+ &mdash;
890
+ <div class='inline'>
891
+ <p>Local path to the file</p>
892
+ </div>
893
+
894
+ </li>
895
+
896
+ <li>
897
+
898
+ <span class='name'>filesize</span>
899
+
900
+
901
+ <span class='type'>(<tt>Int</tt>)</span>
902
+
903
+
904
+
905
+ &mdash;
906
+ <div class='inline'>
907
+ <p>Size of incoming file</p>
908
+ </div>
909
+
910
+ </li>
911
+
912
+ <li>
913
+
914
+ <span class='name'>start_response</span>
915
+
916
+
917
+ <span class='type'>(<tt>Unirest::Response</tt>)</span>
918
+
919
+
920
+
921
+ &mdash;
922
+ <div class='inline'>
923
+ <p>Response body from multipart_start</p>
924
+ </div>
925
+
926
+ </li>
927
+
928
+ </ul>
929
+
930
+ <p class="tag_title">Returns:</p>
931
+ <ul class="return">
932
+
933
+ <li>
934
+
935
+
936
+ <span class='type'>(<tt>Array</tt>)</span>
937
+
938
+
939
+
940
+ </li>
941
+
942
+ </ul>
943
+
944
+ </div><table class="source_code">
945
+ <tr>
946
+ <td>
947
+ <pre class="lines">
948
+
949
+
950
+ 251
951
+ 252
952
+ 253
953
+ 254
954
+ 255
955
+ 256
956
+ 257
957
+ 258</pre>
958
+ </td>
959
+ <td>
960
+ <pre class="code"><span class="info file"># File 'lib/filestack/utils/utils.rb', line 251</span>
961
+
962
+ <span class='kw'>def</span> <span class='id identifier rubyid_create_upload_job_chunks'>create_upload_job_chunks</span><span class='lparen'>(</span><span class='id identifier rubyid_jobs'>jobs</span><span class='comma'>,</span> <span class='id identifier rubyid_state'>state</span><span class='comma'>,</span> <span class='id identifier rubyid_apikey'>apikey</span><span class='comma'>,</span> <span class='id identifier rubyid_filename'>filename</span><span class='comma'>,</span> <span class='id identifier rubyid_filepath'>filepath</span><span class='comma'>,</span> <span class='id identifier rubyid_filesize'>filesize</span><span class='comma'>,</span> <span class='id identifier rubyid_start_response'>start_response</span><span class='rparen'>)</span>
963
+ <span class='id identifier rubyid_jobs'>jobs</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_job'>job</span><span class='op'>|</span>
964
+ <span class='id identifier rubyid_job'>job</span><span class='lbracket'>[</span><span class='symbol'>:chunks</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_chunk_job'><span class='object_link'><a href="#chunk_job-instance_method" title="IntelligentUtils#chunk_job (method)">chunk_job</a></span></span><span class='lparen'>(</span>
965
+ <span class='id identifier rubyid_job'>job</span><span class='comma'>,</span> <span class='id identifier rubyid_state'>state</span><span class='comma'>,</span> <span class='id identifier rubyid_apikey'>apikey</span><span class='comma'>,</span> <span class='id identifier rubyid_filename'>filename</span><span class='comma'>,</span> <span class='id identifier rubyid_filepath'>filepath</span><span class='comma'>,</span> <span class='id identifier rubyid_filesize'>filesize</span><span class='comma'>,</span> <span class='id identifier rubyid_start_response'>start_response</span>
966
+ <span class='rparen'>)</span>
967
+ <span class='rbrace'>}</span>
968
+ <span class='id identifier rubyid_jobs'>jobs</span>
969
+ <span class='kw'>end</span></pre>
970
+ </td>
971
+ </tr>
972
+ </table>
973
+ </div>
974
+
975
+ <div class="method_details ">
976
+ <h3 class="signature " id="get_generator_batch-instance_method">
977
+
978
+ #<strong>get_generator_batch</strong>(generator) &#x21d2; <tt>Array</tt>
979
+
980
+
981
+
982
+
983
+
984
+ </h3><div class="docstring">
985
+ <div class="discussion">
986
+
987
+ <p>Generates a batch given a Fiber</p>
988
+
989
+
990
+ </div>
991
+ </div>
992
+ <div class="tags">
993
+ <p class="tag_title">Parameters:</p>
994
+ <ul class="param">
995
+
996
+ <li>
997
+
998
+ <span class='name'>generator</span>
999
+
1000
+
1001
+ <span class='type'>(<tt>Fiber</tt>)</span>
1002
+
1003
+
1004
+
1005
+ &mdash;
1006
+ <div class='inline'>
1007
+ <p>A living Fiber object</p>
1008
+ </div>
1009
+
1010
+ </li>
1011
+
1012
+ </ul>
1013
+
1014
+ <p class="tag_title">Returns:</p>
1015
+ <ul class="return">
1016
+
1017
+ <li>
1018
+
1019
+
1020
+ <span class='type'>(<tt>Array</tt>)</span>
1021
+
1022
+
1023
+
1024
+ </li>
1025
+
1026
+ </ul>
1027
+
1028
+ </div><table class="source_code">
1029
+ <tr>
1030
+ <td>
1031
+ <pre class="lines">
1032
+
1033
+
1034
+ 156
1035
+ 157
1036
+ 158
1037
+ 159
1038
+ 160
1039
+ 161
1040
+ 162</pre>
1041
+ </td>
1042
+ <td>
1043
+ <pre class="code"><span class="info file"># File 'lib/filestack/utils/utils.rb', line 156</span>
1044
+
1045
+ <span class='kw'>def</span> <span class='id identifier rubyid_get_generator_batch'>get_generator_batch</span><span class='lparen'>(</span><span class='id identifier rubyid_generator'>generator</span><span class='rparen'>)</span>
1046
+ <span class='id identifier rubyid_batch'>batch</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
1047
+ <span class='int'>4</span><span class='period'>.</span><span class='id identifier rubyid_times'>times</span> <span class='kw'>do</span>
1048
+ <span class='id identifier rubyid_batch'>batch</span><span class='period'>.</span><span class='id identifier rubyid_push'>push</span><span class='lparen'>(</span><span class='id identifier rubyid_generator'>generator</span><span class='period'>.</span><span class='id identifier rubyid_resume'>resume</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_generator'>generator</span><span class='period'>.</span><span class='id identifier rubyid_alive?'>alive?</span>
1049
+ <span class='kw'>end</span>
1050
+ <span class='kw'>return</span> <span class='id identifier rubyid_batch'>batch</span>
1051
+ <span class='kw'>end</span></pre>
1052
+ </td>
1053
+ </tr>
1054
+ </table>
1055
+ </div>
1056
+
1057
+ <div class="method_details ">
1058
+ <h3 class="signature " id="run_intelligent_upload_flow-instance_method">
1059
+
1060
+ #<strong>run_intelligent_upload_flow</strong>(jobs, state) &#x21d2; <tt>Array</tt>
1061
+
1062
+
1063
+
1064
+
1065
+
1066
+ </h3><div class="docstring">
1067
+ <div class="discussion">
1068
+
1069
+ <p>Runs the intelligent upload flow, from start to finish</p>
1070
+
1071
+
1072
+ </div>
1073
+ </div>
1074
+ <div class="tags">
1075
+ <p class="tag_title">Parameters:</p>
1076
+ <ul class="param">
1077
+
1078
+ <li>
1079
+
1080
+ <span class='name'>jobs</span>
1081
+
1082
+
1083
+ <span class='type'>(<tt>Array</tt>)</span>
1084
+
1085
+
1086
+
1087
+ &mdash;
1088
+ <div class='inline'>
1089
+ <p>A list of file parts</p>
1090
+ </div>
1091
+
1092
+ </li>
1093
+
1094
+ <li>
1095
+
1096
+ <span class='name'>state</span>
1097
+
1098
+
1099
+ <span class='type'>(<tt><span class='object_link'><a href="IntelligentState.html" title="IntelligentState (class)">IntelligentState</a></span></tt>)</span>
1100
+
1101
+
1102
+
1103
+ &mdash;
1104
+ <div class='inline'>
1105
+ <p>An IntelligentState object</p>
1106
+ </div>
1107
+
1108
+ </li>
1109
+
1110
+ </ul>
1111
+
1112
+ <p class="tag_title">Returns:</p>
1113
+ <ul class="return">
1114
+
1115
+ <li>
1116
+
1117
+
1118
+ <span class='type'>(<tt>Array</tt>)</span>
1119
+
1120
+
1121
+
1122
+ </li>
1123
+
1124
+ </ul>
1125
+
1126
+ </div><table class="source_code">
1127
+ <tr>
1128
+ <td>
1129
+ <pre class="lines">
1130
+
1131
+
1132
+ 196
1133
+ 197
1134
+ 198
1135
+ 199
1136
+ 200
1137
+ 201
1138
+ 202
1139
+ 203
1140
+ 204
1141
+ 205
1142
+ 206
1143
+ 207
1144
+ 208
1145
+ 209
1146
+ 210
1147
+ 211
1148
+ 212
1149
+ 213
1150
+ 214
1151
+ 215
1152
+ 216
1153
+ 217
1154
+ 218
1155
+ 219
1156
+ 220
1157
+ 221
1158
+ 222</pre>
1159
+ </td>
1160
+ <td>
1161
+ <pre class="code"><span class="info file"># File 'lib/filestack/utils/utils.rb', line 196</span>
1162
+
1163
+ <span class='kw'>def</span> <span class='id identifier rubyid_run_intelligent_upload_flow'>run_intelligent_upload_flow</span><span class='lparen'>(</span><span class='id identifier rubyid_jobs'>jobs</span><span class='comma'>,</span> <span class='id identifier rubyid_state'>state</span><span class='rparen'>)</span>
1164
+ <span class='id identifier rubyid_bar'>bar</span> <span class='op'>=</span> <span class='const'>ProgressBar</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_jobs'>jobs</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span><span class='rparen'>)</span>
1165
+ <span class='id identifier rubyid_generator'>generator</span> <span class='op'>=</span> <span class='id identifier rubyid_create_intelligent_generator'><span class='object_link'><a href="#create_intelligent_generator-instance_method" title="IntelligentUtils#create_intelligent_generator (method)">create_intelligent_generator</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_jobs'>jobs</span><span class='rparen'>)</span>
1166
+ <span class='id identifier rubyid_working_offset'>working_offset</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FilestackConfig.html" title="FilestackConfig (class)">FilestackConfig</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FilestackConfig.html#DEFAULT_OFFSET_SIZE-constant" title="FilestackConfig::DEFAULT_OFFSET_SIZE (constant)">DEFAULT_OFFSET_SIZE</a></span></span>
1167
+ <span class='kw'>while</span> <span class='id identifier rubyid_generator'>generator</span><span class='period'>.</span><span class='id identifier rubyid_alive?'>alive?</span>
1168
+ <span class='id identifier rubyid_batch'>batch</span> <span class='op'>=</span> <span class='id identifier rubyid_get_generator_batch'><span class='object_link'><a href="#get_generator_batch-instance_method" title="IntelligentUtils#get_generator_batch (method)">get_generator_batch</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_generator'>generator</span><span class='rparen'>)</span>
1169
+ <span class='comment'># run parts
1170
+ </span> <span class='const'>Parallel</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='id identifier rubyid_batch'>batch</span><span class='comma'>,</span> <span class='label'>in_threads:</span> <span class='int'>4</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_part'>part</span><span class='op'>|</span>
1171
+ <span class='id identifier rubyid_state'>state</span> <span class='op'>=</span> <span class='id identifier rubyid_run_intelligent_uploads'><span class='object_link'><a href="#run_intelligent_uploads-instance_method" title="IntelligentUtils#run_intelligent_uploads (method)">run_intelligent_uploads</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_part'>part</span><span class='comma'>,</span> <span class='id identifier rubyid_state'>state</span><span class='rparen'>)</span>
1172
+ <span class='comment'># condition: a chunk has failed but we have not reached the maximum retries
1173
+ </span> <span class='kw'>while</span> <span class='id identifier rubyid_bad_state'><span class='object_link'><a href="#bad_state-instance_method" title="IntelligentUtils#bad_state (method)">bad_state</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_state'>state</span><span class='rparen'>)</span>
1174
+ <span class='comment'># condition: timeout to S3, requiring offset size to be changed
1175
+ </span> <span class='kw'>if</span> <span class='id identifier rubyid_state'>state</span><span class='period'>.</span><span class='id identifier rubyid_error_type'>error_type</span> <span class='op'>==</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>S3_NETWORK</span><span class='tstring_end'>&#39;</span></span>
1176
+ <span class='id identifier rubyid_sleep'>sleep</span><span class='lparen'>(</span><span class='int'>5</span><span class='rparen'>)</span>
1177
+ <span class='id identifier rubyid_state'>state</span><span class='period'>.</span><span class='id identifier rubyid_offset'>offset</span> <span class='op'>=</span> <span class='id identifier rubyid_working_offset'>working_offset</span> <span class='op'>=</span> <span class='id identifier rubyid_change_offset'><span class='object_link'><a href="#change_offset-instance_method" title="IntelligentUtils#change_offset (method)">change_offset</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_working_offset'>working_offset</span><span class='comma'>,</span> <span class='id identifier rubyid_state'>state</span><span class='rparen'>)</span>
1178
+ <span class='comment'># condition: timeout to backend, requiring only backoff
1179
+ </span> <span class='kw'>elsif</span> <span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>S3_SERVER</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>BACKEND_SERVER</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span> <span class='id identifier rubyid_state'>state</span><span class='period'>.</span><span class='id identifier rubyid_error_type'>error_type</span>
1180
+ <span class='id identifier rubyid_sleep'>sleep</span><span class='lparen'>(</span><span class='id identifier rubyid_state'>state</span><span class='period'>.</span><span class='id identifier rubyid_backoff'>backoff</span><span class='rparen'>)</span>
1181
+ <span class='kw'>end</span>
1182
+ <span class='id identifier rubyid_state'>state</span><span class='period'>.</span><span class='id identifier rubyid_add_retry'>add_retry</span>
1183
+ <span class='id identifier rubyid_state'>state</span> <span class='op'>=</span> <span class='id identifier rubyid_run_intelligent_uploads'><span class='object_link'><a href="#run_intelligent_uploads-instance_method" title="IntelligentUtils#run_intelligent_uploads (method)">run_intelligent_uploads</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_part'>part</span><span class='comma'>,</span> <span class='id identifier rubyid_state'>state</span><span class='rparen'>)</span>
1184
+ <span class='kw'>end</span>
1185
+ <span class='id identifier rubyid_raise'>raise</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Upload has failed. Please try again later.</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>unless</span> <span class='id identifier rubyid_state'>state</span><span class='period'>.</span><span class='id identifier rubyid_ok'>ok</span>
1186
+ <span class='id identifier rubyid_bar'>bar</span><span class='period'>.</span><span class='id identifier rubyid_increment!'>increment!</span>
1187
+ <span class='kw'>end</span>
1188
+ <span class='kw'>end</span>
1189
+ <span class='kw'>end</span></pre>
1190
+ </td>
1191
+ </tr>
1192
+ </table>
1193
+ </div>
1194
+
1195
+ <div class="method_details ">
1196
+ <h3 class="signature " id="run_intelligent_uploads-instance_method">
1197
+
1198
+ #<strong>run_intelligent_uploads</strong>(part, state) &#x21d2; <tt><span class='object_link'><a href="IntelligentState.html" title="IntelligentState (class)">IntelligentState</a></span></tt>
1199
+
1200
+
1201
+
1202
+
1203
+
1204
+ </h3><div class="docstring">
1205
+ <div class="discussion">
1206
+
1207
+ <p>Send a job&#39;s chunks in parallel and commit</p>
1208
+
1209
+
1210
+ </div>
1211
+ </div>
1212
+ <div class="tags">
1213
+ <p class="tag_title">Parameters:</p>
1214
+ <ul class="param">
1215
+
1216
+ <li>
1217
+
1218
+ <span class='name'>part</span>
1219
+
1220
+
1221
+ <span class='type'>(<tt>Dict</tt>)</span>
1222
+
1223
+
1224
+
1225
+ &mdash;
1226
+ <div class='inline'>
1227
+ <p>A dictionary representing the information for a single part</p>
1228
+ </div>
1229
+
1230
+ </li>
1231
+
1232
+ <li>
1233
+
1234
+ <span class='name'>state</span>
1235
+
1236
+
1237
+ <span class='type'>(<tt><span class='object_link'><a href="IntelligentState.html" title="IntelligentState (class)">IntelligentState</a></span></tt>)</span>
1238
+
1239
+
1240
+
1241
+ &mdash;
1242
+ <div class='inline'>
1243
+ <p>An IntelligentState object</p>
1244
+ </div>
1245
+
1246
+ </li>
1247
+
1248
+ </ul>
1249
+
1250
+ <p class="tag_title">Returns:</p>
1251
+ <ul class="return">
1252
+
1253
+ <li>
1254
+
1255
+
1256
+ <span class='type'>(<tt><span class='object_link'><a href="IntelligentState.html" title="IntelligentState (class)">IntelligentState</a></span></tt>)</span>
1257
+
1258
+
1259
+
1260
+ </li>
1261
+
1262
+ </ul>
1263
+
1264
+ </div><table class="source_code">
1265
+ <tr>
1266
+ <td>
1267
+ <pre class="lines">
1268
+
1269
+
1270
+ 303
1271
+ 304
1272
+ 305
1273
+ 306
1274
+ 307
1275
+ 308
1276
+ 309
1277
+ 310
1278
+ 311
1279
+ 312
1280
+ 313
1281
+ 314
1282
+ 315
1283
+ 316
1284
+ 317
1285
+ 318
1286
+ 319
1287
+ 320
1288
+ 321
1289
+ 322
1290
+ 323
1291
+ 324
1292
+ 325
1293
+ 326
1294
+ 327
1295
+ 328
1296
+ 329
1297
+ 330
1298
+ 331
1299
+ 332
1300
+ 333
1301
+ 334
1302
+ 335
1303
+ 336
1304
+ 337
1305
+ 338
1306
+ 339
1307
+ 340
1308
+ 341
1309
+ 342
1310
+ 343
1311
+ 344</pre>
1312
+ </td>
1313
+ <td>
1314
+ <pre class="code"><span class="info file"># File 'lib/filestack/utils/utils.rb', line 303</span>
1315
+
1316
+ <span class='kw'>def</span> <span class='id identifier rubyid_run_intelligent_uploads'>run_intelligent_uploads</span><span class='lparen'>(</span><span class='id identifier rubyid_part'>part</span><span class='comma'>,</span> <span class='id identifier rubyid_state'>state</span><span class='rparen'>)</span>
1317
+ <span class='id identifier rubyid_failed'>failed</span> <span class='op'>=</span> <span class='kw'>false</span>
1318
+ <span class='id identifier rubyid_chunks'>chunks</span> <span class='op'>=</span> <span class='id identifier rubyid_chunk_job'><span class='object_link'><a href="#chunk_job-instance_method" title="IntelligentUtils#chunk_job (method)">chunk_job</a></span></span><span class='lparen'>(</span>
1319
+ <span class='id identifier rubyid_part'>part</span><span class='comma'>,</span> <span class='id identifier rubyid_state'>state</span><span class='comma'>,</span> <span class='id identifier rubyid_part'>part</span><span class='lbracket'>[</span><span class='symbol'>:apikey</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_part'>part</span><span class='lbracket'>[</span><span class='symbol'>:filename</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_part'>part</span><span class='lbracket'>[</span><span class='symbol'>:filepath</span><span class='rbracket'>]</span><span class='comma'>,</span>
1320
+ <span class='id identifier rubyid_part'>part</span><span class='lbracket'>[</span><span class='symbol'>:filesize</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_part'>part</span><span class='lbracket'>[</span><span class='symbol'>:start_response</span><span class='rbracket'>]</span>
1321
+ <span class='rparen'>)</span>
1322
+ <span class='const'>Parallel</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='id identifier rubyid_chunks'>chunks</span><span class='comma'>,</span> <span class='label'>in_threads:</span> <span class='int'>3</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_chunk'>chunk</span><span class='op'>|</span>
1323
+ <span class='kw'>begin</span>
1324
+ <span class='id identifier rubyid_upload_chunk_intelligently'><span class='object_link'><a href="#upload_chunk_intelligently-instance_method" title="IntelligentUtils#upload_chunk_intelligently (method)">upload_chunk_intelligently</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_chunk'>chunk</span><span class='comma'>,</span> <span class='id identifier rubyid_state'>state</span><span class='comma'>,</span> <span class='id identifier rubyid_part'>part</span><span class='lbracket'>[</span><span class='symbol'>:apikey</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_part'>part</span><span class='lbracket'>[</span><span class='symbol'>:filepath</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_part'>part</span><span class='lbracket'>[</span><span class='symbol'>:options</span><span class='rbracket'>]</span><span class='rparen'>)</span>
1325
+ <span class='kw'>rescue</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
1326
+ <span class='id identifier rubyid_state'>state</span><span class='period'>.</span><span class='id identifier rubyid_error_type'>error_type</span> <span class='op'>=</span> <span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_message'>message</span>
1327
+ <span class='id identifier rubyid_failed'>failed</span> <span class='op'>=</span> <span class='kw'>true</span>
1328
+ <span class='const'>Parallel</span><span class='op'>::</span><span class='const'>Kill</span>
1329
+ <span class='kw'>end</span>
1330
+ <span class='kw'>end</span>
1331
+
1332
+ <span class='kw'>if</span> <span class='id identifier rubyid_failed'>failed</span>
1333
+ <span class='id identifier rubyid_state'>state</span><span class='period'>.</span><span class='id identifier rubyid_ok'>ok</span> <span class='op'>=</span> <span class='kw'>false</span>
1334
+ <span class='kw'>return</span> <span class='id identifier rubyid_state'>state</span>
1335
+ <span class='kw'>else</span>
1336
+ <span class='id identifier rubyid_state'>state</span><span class='period'>.</span><span class='id identifier rubyid_ok'>ok</span> <span class='op'>=</span> <span class='kw'>true</span>
1337
+ <span class='kw'>end</span>
1338
+ <span class='id identifier rubyid_commit_params'>commit_params</span> <span class='op'>=</span> <span class='lbrace'>{</span>
1339
+ <span class='label'>apikey:</span> <span class='id identifier rubyid_part'>part</span><span class='lbracket'>[</span><span class='symbol'>:apikey</span><span class='rbracket'>]</span><span class='comma'>,</span>
1340
+ <span class='label'>uri:</span> <span class='id identifier rubyid_part'>part</span><span class='lbracket'>[</span><span class='symbol'>:uri</span><span class='rbracket'>]</span><span class='comma'>,</span>
1341
+ <span class='label'>region:</span> <span class='id identifier rubyid_part'>part</span><span class='lbracket'>[</span><span class='symbol'>:region</span><span class='rbracket'>]</span><span class='comma'>,</span>
1342
+ <span class='label'>upload_id:</span> <span class='id identifier rubyid_part'>part</span><span class='lbracket'>[</span><span class='symbol'>:upload_id</span><span class='rbracket'>]</span><span class='comma'>,</span>
1343
+ <span class='label'>size:</span> <span class='id identifier rubyid_part'>part</span><span class='lbracket'>[</span><span class='symbol'>:filesize</span><span class='rbracket'>]</span><span class='comma'>,</span>
1344
+ <span class='label'>part:</span> <span class='id identifier rubyid_part'>part</span><span class='lbracket'>[</span><span class='symbol'>:part</span><span class='rbracket'>]</span><span class='comma'>,</span>
1345
+ <span class='label'>location_url:</span> <span class='id identifier rubyid_part'>part</span><span class='lbracket'>[</span><span class='symbol'>:location_url</span><span class='rbracket'>]</span><span class='comma'>,</span>
1346
+ <span class='label'>store_location:</span> <span class='id identifier rubyid_part'>part</span><span class='lbracket'>[</span><span class='symbol'>:store_location</span><span class='rbracket'>]</span><span class='comma'>,</span>
1347
+ <span class='label'>file:</span> <span class='const'>Tempfile</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_part'>part</span><span class='lbracket'>[</span><span class='symbol'>:filename</span><span class='rbracket'>]</span><span class='rparen'>)</span>
1348
+ <span class='rbrace'>}</span>
1349
+ <span class='id identifier rubyid_response'>response</span> <span class='op'>=</span> <span class='const'>Unirest</span><span class='period'>.</span><span class='id identifier rubyid_post'>post</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="FilestackConfig.html" title="FilestackConfig (class)">FilestackConfig</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FilestackConfig.html#MULTIPART_COMMIT_URL-constant" title="FilestackConfig::MULTIPART_COMMIT_URL (constant)">MULTIPART_COMMIT_URL</a></span></span><span class='comma'>,</span> <span class='label'>parameters:</span> <span class='id identifier rubyid_commit_params'>commit_params</span><span class='comma'>,</span>
1350
+ <span class='label'>headers:</span> <span class='const'><span class='object_link'><a href="FilestackConfig.html" title="FilestackConfig (class)">FilestackConfig</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FilestackConfig.html#HEADERS-constant" title="FilestackConfig::HEADERS (constant)">HEADERS</a></span></span><span class='rparen'>)</span>
1351
+ <span class='kw'>if</span> <span class='id identifier rubyid_response'>response</span><span class='period'>.</span><span class='id identifier rubyid_code'>code</span> <span class='op'>==</span> <span class='int'>200</span>
1352
+ <span class='id identifier rubyid_state'>state</span><span class='period'>.</span><span class='id identifier rubyid_reset'>reset</span>
1353
+ <span class='kw'>else</span>
1354
+ <span class='id identifier rubyid_state'>state</span><span class='period'>.</span><span class='id identifier rubyid_ok'>ok</span> <span class='op'>=</span> <span class='kw'>false</span>
1355
+ <span class='kw'>end</span>
1356
+ <span class='id identifier rubyid_state'>state</span>
1357
+ <span class='kw'>end</span></pre>
1358
+ </td>
1359
+ </tr>
1360
+ </table>
1361
+ </div>
1362
+
1363
+ <div class="method_details ">
1364
+ <h3 class="signature " id="upload_chunk_intelligently-instance_method">
1365
+
1366
+ #<strong>upload_chunk_intelligently</strong>(job, state, apikey, filepath, options) &#x21d2; <tt>Unirest::Response</tt>
1367
+
1368
+
1369
+
1370
+
1371
+
1372
+ </h3><div class="docstring">
1373
+ <div class="discussion">
1374
+
1375
+ <p>Upload a single chunk</p>
1376
+
1377
+
1378
+ </div>
1379
+ </div>
1380
+ <div class="tags">
1381
+ <p class="tag_title">Parameters:</p>
1382
+ <ul class="param">
1383
+
1384
+ <li>
1385
+
1386
+ <span class='name'>job</span>
1387
+
1388
+
1389
+ <span class='type'>(<tt>Dict</tt>)</span>
1390
+
1391
+
1392
+
1393
+ &mdash;
1394
+ <div class='inline'>
1395
+ <p>Dictionary with all job options</p>
1396
+ </div>
1397
+
1398
+ </li>
1399
+
1400
+ <li>
1401
+
1402
+ <span class='name'>state</span>
1403
+
1404
+
1405
+ <span class='type'>(<tt><span class='object_link'><a href="IntelligentState.html" title="IntelligentState (class)">IntelligentState</a></span></tt>)</span>
1406
+
1407
+
1408
+
1409
+ &mdash;
1410
+ <div class='inline'>
1411
+ <p>An IntelligentState object</p>
1412
+ </div>
1413
+
1414
+ </li>
1415
+
1416
+ <li>
1417
+
1418
+ <span class='name'>apikey</span>
1419
+
1420
+
1421
+ <span class='type'>(<tt>String</tt>)</span>
1422
+
1423
+
1424
+
1425
+ &mdash;
1426
+ <div class='inline'>
1427
+ <p>Filestack API key</p>
1428
+ </div>
1429
+
1430
+ </li>
1431
+
1432
+ <li>
1433
+
1434
+ <span class='name'>filename</span>
1435
+
1436
+
1437
+ <span class='type'>(<tt>String</tt>)</span>
1438
+
1439
+
1440
+
1441
+ &mdash;
1442
+ <div class='inline'>
1443
+ <p>Name of incoming file</p>
1444
+ </div>
1445
+
1446
+ </li>
1447
+
1448
+ <li>
1449
+
1450
+ <span class='name'>filepath</span>
1451
+
1452
+
1453
+ <span class='type'>(<tt>String</tt>)</span>
1454
+
1455
+
1456
+
1457
+ &mdash;
1458
+ <div class='inline'>
1459
+ <p>Local path to the file</p>
1460
+ </div>
1461
+
1462
+ </li>
1463
+
1464
+ <li>
1465
+
1466
+ <span class='name'>options</span>
1467
+
1468
+
1469
+ <span class='type'>(<tt>Hash</tt>)</span>
1470
+
1471
+
1472
+
1473
+ &mdash;
1474
+ <div class='inline'>
1475
+ <p>User-defined options for multipart uploads</p>
1476
+ </div>
1477
+
1478
+ </li>
1479
+
1480
+ </ul>
1481
+
1482
+ <p class="tag_title">Returns:</p>
1483
+ <ul class="return">
1484
+
1485
+ <li>
1486
+
1487
+
1488
+ <span class='type'>(<tt>Unirest::Response</tt>)</span>
1489
+
1490
+
1491
+
1492
+ </li>
1493
+
1494
+ </ul>
1495
+
1496
+ </div><table class="source_code">
1497
+ <tr>
1498
+ <td>
1499
+ <pre class="lines">
1500
+
1501
+
1502
+ 357
1503
+ 358
1504
+ 359
1505
+ 360
1506
+ 361
1507
+ 362
1508
+ 363
1509
+ 364
1510
+ 365
1511
+ 366
1512
+ 367
1513
+ 368
1514
+ 369
1515
+ 370
1516
+ 371
1517
+ 372
1518
+ 373
1519
+ 374
1520
+ 375
1521
+ 376
1522
+ 377
1523
+ 378
1524
+ 379
1525
+ 380
1526
+ 381
1527
+ 382
1528
+ 383
1529
+ 384
1530
+ 385
1531
+ 386
1532
+ 387
1533
+ 388
1534
+ 389
1535
+ 390
1536
+ 391
1537
+ 392
1538
+ 393
1539
+ 394
1540
+ 395
1541
+ 396
1542
+ 397
1543
+ 398
1544
+ 399
1545
+ 400
1546
+ 401
1547
+ 402
1548
+ 403
1549
+ 404
1550
+ 405
1551
+ 406
1552
+ 407
1553
+ 408
1554
+ 409
1555
+ 410
1556
+ 411
1557
+ 412
1558
+ 413
1559
+ 414</pre>
1560
+ </td>
1561
+ <td>
1562
+ <pre class="code"><span class="info file"># File 'lib/filestack/utils/utils.rb', line 357</span>
1563
+
1564
+ <span class='kw'>def</span> <span class='id identifier rubyid_upload_chunk_intelligently'>upload_chunk_intelligently</span><span class='lparen'>(</span><span class='id identifier rubyid_job'>job</span><span class='comma'>,</span> <span class='id identifier rubyid_state'>state</span><span class='comma'>,</span> <span class='id identifier rubyid_apikey'>apikey</span><span class='comma'>,</span> <span class='id identifier rubyid_filepath'>filepath</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
1565
+ <span class='id identifier rubyid_file'>file</span> <span class='op'>=</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_open'>open</span><span class='lparen'>(</span><span class='id identifier rubyid_filepath'>filepath</span><span class='rparen'>)</span>
1566
+ <span class='id identifier rubyid_file'>file</span><span class='period'>.</span><span class='id identifier rubyid_seek'>seek</span><span class='lparen'>(</span><span class='id identifier rubyid_job'>job</span><span class='lbracket'>[</span><span class='symbol'>:seek</span><span class='rbracket'>]</span> <span class='op'>+</span> <span class='id identifier rubyid_job'>job</span><span class='lbracket'>[</span><span class='symbol'>:offset</span><span class='rbracket'>]</span><span class='rparen'>)</span>
1567
+ <span class='id identifier rubyid_chunk'>chunk</span> <span class='op'>=</span> <span class='id identifier rubyid_file'>file</span><span class='period'>.</span><span class='id identifier rubyid_read'>read</span><span class='lparen'>(</span><span class='id identifier rubyid_state'>state</span><span class='period'>.</span><span class='id identifier rubyid_offset'>offset</span><span class='rparen'>)</span>
1568
+ <span class='id identifier rubyid_md5'>md5</span> <span class='op'>=</span> <span class='const'>Digest</span><span class='op'>::</span><span class='const'>MD5</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
1569
+ <span class='id identifier rubyid_md5'>md5</span> <span class='op'>&lt;&lt;</span> <span class='id identifier rubyid_chunk'>chunk</span>
1570
+ <span class='id identifier rubyid_data'>data</span> <span class='op'>=</span> <span class='lbrace'>{</span>
1571
+ <span class='label'>apikey:</span> <span class='id identifier rubyid_apikey'>apikey</span><span class='comma'>,</span>
1572
+ <span class='label'>part:</span> <span class='id identifier rubyid_job'>job</span><span class='lbracket'>[</span><span class='symbol'>:part</span><span class='rbracket'>]</span><span class='comma'>,</span>
1573
+ <span class='label'>size:</span> <span class='id identifier rubyid_chunk'>chunk</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span><span class='comma'>,</span>
1574
+ <span class='label'>md5:</span> <span class='id identifier rubyid_md5'>md5</span><span class='period'>.</span><span class='id identifier rubyid_base64digest'>base64digest</span><span class='comma'>,</span>
1575
+ <span class='label'>uri:</span> <span class='id identifier rubyid_job'>job</span><span class='lbracket'>[</span><span class='symbol'>:uri</span><span class='rbracket'>]</span><span class='comma'>,</span>
1576
+ <span class='label'>region:</span> <span class='id identifier rubyid_job'>job</span><span class='lbracket'>[</span><span class='symbol'>:region</span><span class='rbracket'>]</span><span class='comma'>,</span>
1577
+ <span class='label'>upload_id:</span> <span class='id identifier rubyid_job'>job</span><span class='lbracket'>[</span><span class='symbol'>:upload_id</span><span class='rbracket'>]</span><span class='comma'>,</span>
1578
+ <span class='label'>store_location:</span> <span class='id identifier rubyid_job'>job</span><span class='lbracket'>[</span><span class='symbol'>:store_location</span><span class='rbracket'>]</span><span class='comma'>,</span>
1579
+ <span class='label'>offset:</span> <span class='id identifier rubyid_job'>job</span><span class='lbracket'>[</span><span class='symbol'>:offset</span><span class='rbracket'>]</span><span class='comma'>,</span>
1580
+ <span class='label'>file:</span> <span class='const'>Tempfile</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_job'>job</span><span class='lbracket'>[</span><span class='symbol'>:filename</span><span class='rbracket'>]</span><span class='rparen'>)</span><span class='comma'>,</span>
1581
+ <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>multipart</span><span class='tstring_end'>&#39;</span></span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>true</span><span class='tstring_end'>&#39;</span></span>
1582
+ <span class='rbrace'>}</span>
1583
+
1584
+ <span class='id identifier rubyid_data'>data</span> <span class='op'>=</span> <span class='id identifier rubyid_data'>data</span><span class='period'>.</span><span class='id identifier rubyid_merge!'>merge!</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_options'>options</span>
1585
+ <span class='id identifier rubyid_fs_response'>fs_response</span> <span class='op'>=</span> <span class='const'>Unirest</span><span class='period'>.</span><span class='id identifier rubyid_post'>post</span><span class='lparen'>(</span>
1586
+ <span class='const'><span class='object_link'><a href="FilestackConfig.html" title="FilestackConfig (class)">FilestackConfig</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FilestackConfig.html#MULTIPART_UPLOAD_URL-constant" title="FilestackConfig::MULTIPART_UPLOAD_URL (constant)">MULTIPART_UPLOAD_URL</a></span></span><span class='comma'>,</span> <span class='label'>parameters:</span> <span class='id identifier rubyid_data'>data</span><span class='comma'>,</span>
1587
+ <span class='label'>headers:</span> <span class='const'><span class='object_link'><a href="FilestackConfig.html" title="FilestackConfig (class)">FilestackConfig</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FilestackConfig.html#HEADERS-constant" title="FilestackConfig::HEADERS (constant)">HEADERS</a></span></span>
1588
+ <span class='rparen'>)</span>
1589
+ <span class='comment'># POST to multipart/upload
1590
+ </span> <span class='kw'>begin</span>
1591
+ <span class='kw'>unless</span> <span class='id identifier rubyid_fs_response'>fs_response</span><span class='period'>.</span><span class='id identifier rubyid_code'>code</span> <span class='op'>==</span> <span class='int'>200</span>
1592
+ <span class='kw'>if</span> <span class='lbracket'>[</span><span class='int'>400</span><span class='comma'>,</span> <span class='int'>403</span><span class='comma'>,</span> <span class='int'>404</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span> <span class='id identifier rubyid_fs_response'>fs_response</span><span class='period'>.</span><span class='id identifier rubyid_code'>code</span>
1593
+ <span class='id identifier rubyid_raise'>raise</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>FAILURE</span><span class='tstring_end'>&#39;</span></span>
1594
+ <span class='kw'>else</span>
1595
+ <span class='id identifier rubyid_raise'>raise</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>BACKEND_SERVER</span><span class='tstring_end'>&#39;</span></span>
1596
+ <span class='kw'>end</span>
1597
+ <span class='kw'>end</span>
1598
+
1599
+ <span class='kw'>rescue</span>
1600
+ <span class='id identifier rubyid_raise'>raise</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>BACKEND_NETWORK</span><span class='tstring_end'>&#39;</span></span>
1601
+ <span class='kw'>end</span>
1602
+ <span class='id identifier rubyid_fs_response'>fs_response</span> <span class='op'>=</span> <span class='id identifier rubyid_fs_response'>fs_response</span><span class='period'>.</span><span class='id identifier rubyid_body'>body</span>
1603
+
1604
+ <span class='comment'># PUT to S3
1605
+ </span> <span class='kw'>begin</span>
1606
+ <span class='id identifier rubyid_amazon_response'>amazon_response</span> <span class='op'>=</span> <span class='const'>Unirest</span><span class='period'>.</span><span class='id identifier rubyid_put'>put</span><span class='lparen'>(</span>
1607
+ <span class='id identifier rubyid_fs_response'>fs_response</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>url</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='label'>headers:</span> <span class='id identifier rubyid_fs_response'>fs_response</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>headers</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='label'>parameters:</span> <span class='id identifier rubyid_chunk'>chunk</span>
1608
+ <span class='rparen'>)</span>
1609
+ <span class='kw'>unless</span> <span class='id identifier rubyid_amazon_response'>amazon_response</span><span class='period'>.</span><span class='id identifier rubyid_code'>code</span> <span class='op'>==</span> <span class='int'>200</span>
1610
+ <span class='kw'>if</span> <span class='lbracket'>[</span><span class='int'>400</span><span class='comma'>,</span> <span class='int'>403</span><span class='comma'>,</span> <span class='int'>404</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span> <span class='id identifier rubyid_amazon_response'>amazon_response</span><span class='period'>.</span><span class='id identifier rubyid_code'>code</span>
1611
+ <span class='id identifier rubyid_raise'>raise</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>FAILURE</span><span class='tstring_end'>&#39;</span></span>
1612
+ <span class='kw'>else</span>
1613
+ <span class='id identifier rubyid_raise'>raise</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>S3_SERVER</span><span class='tstring_end'>&#39;</span></span>
1614
+ <span class='kw'>end</span>
1615
+ <span class='kw'>end</span>
1616
+
1617
+ <span class='kw'>rescue</span>
1618
+ <span class='id identifier rubyid_raise'>raise</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>S3_NETWORK</span><span class='tstring_end'>&#39;</span></span>
1619
+ <span class='kw'>end</span>
1620
+ <span class='id identifier rubyid_amazon_response'>amazon_response</span>
1621
+ <span class='kw'>end</span></pre>
1622
+ </td>
1623
+ </tr>
1624
+ </table>
1625
+ </div>
1626
+
1627
+ </div>
1628
+
1629
+ </div>
1630
+
1631
+ <div id="footer">
1632
+ Generated on Thu Aug 17 10:04:38 2017 by
1633
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1634
+ 0.9.9 (ruby-2.4.0).
1635
+ </div>
1636
+
1637
+ </div>
1638
+ </body>
1639
+ </html>