1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 | var Vimeo = require('../index').Vimeo;
|
19 |
|
20 | try {
|
21 | var config = require('./config.json');
|
22 | } catch (error) {
|
23 | console.error('ERROR: For this example to run properly you must create an api app at developer.vimeo.com/apps/new and set your callback url to http://localhost:8080/oauth_callback');
|
24 | console.error('ERROR: Once you have your app, make a copy of config.json.example named "config.json" and add your client id, client secret and access token');
|
25 | return;
|
26 | }
|
27 |
|
28 | var lib = new Vimeo(config.client_id, config.client_secret);
|
29 | if (!config.access_token) {
|
30 | throw new Error('You can not upload a video without configuring an access token');
|
31 | }
|
32 |
|
33 |
|
34 | var file_path = process.argv[2];
|
35 |
|
36 | lib.access_token = config.access_token;
|
37 | lib.streamingUpload(file_path, function (err, body, status, headers) {
|
38 | if (err) {
|
39 | return console.log(err);
|
40 | }
|
41 | console.log(status);
|
42 | console.log(headers.location);
|
43 | });
|