forked from transloadit/node-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate_api.js
47 lines (40 loc) · 1.47 KB
/
template_api.js
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
45
46
47
// Run this file as:
//
// env TRANSLOADIT_KEY=xxx TRANSLOADIT_SECRET=yyy node template_api.js
//
// You'll likely just want to `require('transloadit')`, but we're requiring the local
// variant here for easier testing:
const Transloadit = require('../src/Transloadit')
const transloadit = new Transloadit({
authKey : process.env.TRANSLOADIT_KEY,
authSecret: process.env.TRANSLOADIT_SECRET,
})
const template = {
steps: {
encode: {
use : ':original',
robot : '/video/encode',
preset: 'ipad-high',
},
thumbnail: {
use : 'encode',
robot: '/video/thumbnails',
},
},
};
(async () => {
try {
const { count } = await transloadit.listTemplates({ sort: 'created', order: 'asc' })
console.log('Successfully fetched', count, 'template(s)')
const createTemplateResult = await transloadit.createTemplate({ name: 'node-sdk-test1', template })
console.log('Template created successfully:', createTemplateResult)
const editResult = await transloadit.editTemplate(createTemplateResult.id, { name: 'node-sdk-test2', template })
console.log('Successfully edited template', editResult)
const getTemplateResult = await transloadit.getTemplate(createTemplateResult.id)
console.log('Successfully fetched template', getTemplateResult)
const delResult = await transloadit.deleteTemplate(createTemplateResult.id)
console.log('Successfully deleted template', delResult)
} catch (err) {
console.error(err)
}
})()