forked from filestack/filestack-php
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathintelligent-ingestion.php
45 lines (38 loc) · 1.31 KB
/
intelligent-ingestion.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
/**
* Upload File via Intelligent Ingestion Examples
*
* The Intelligent Ingestion feature allows user to upload a file in chunks of
* not precised size. This creates a more stable upload flow that ensures the
* file being uploaded will eventually complete successfully, regardless of
* network latency or timeout errors.
*
* However, the upload process may be slower than the normal upload flow for
* large files, as there are errors are retried using the exponential backoff
* retry strategy.
*
* Lastly, this feature has to be turned on for the apikey being used. To turn
* on this feature please contact Filestack at [email protected].
*
*/
use Filestack\FilestackClient;
use Filestack\Filelink;
use Filestack\FilestackException;
$test_api_key = 'YOUR_FILESTACK_API_KEY';
$test_filepath = __DIR__ . '/../tests/testfiles/some-big-video-file.mp4';
$client = new FilestackClient($test_api_key);
// upload a file
$filelink = null;
try {
$filelink = $client->upload($test_filepath, ['intelligent' => true]);
var_dump($filelink);
} catch (FilestackException $e) {
echo $e->getMessage();
echo $e->getCode();
}
// get metadata of file
$fields = [];
$metadata = $client->getMetaData($filelink->handle, $fields);
# or
$metadata = $client->getMetaData($filelink->url(), $fields);
var_dump($metadata);