UNPKG

1.83 kBJavaScriptView Raw
1"use strict";
2/**
3 * Copyright 2013 Vimeo
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18var Vimeo = require('../index').Vimeo;
19
20try {
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// Here we have to build the vimeo library using the client_id, client_secret and an access token
29// For the request we make below (/channels) the access token can be a client access token instead of a user access token.
30var lib = new Vimeo(config.client_id, config.client_secret);
31lib.access_token = config.access_token;
32
33// Make an API request
34lib.streamingUpload(__dirname + '/test.mp4', function (error, body, status_code, headers) {
35 if (error) {
36 console.log('error');
37 console.log(error);
38 } else {
39 console.log('body');
40 console.log(body);
41 }
42
43 console.log('status code');
44 console.log(status_code);
45 console.log('headers');
46 console.log(headers);
47});
48
49require('repl').start('hi');
\No newline at end of file