-
-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathupload.examples.js
39 lines (33 loc) · 952 Bytes
/
upload.examples.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
'use strict';
const { log, store } = require('./services');
//#upload-image-example
const uploadImage = client =>
client
.upload('./assets/placeholder.md', 'Heroes', 'image')
.then(result => log('upload-image-example', result));
//#
const uploadSpecificImage = client =>
client
.find('Heroes', [{ name: 'yoda' }], { limit: 1 })
.then(response => response.data[0].recordId)
.then(recordId => {
setTimeout(
() =>
//#upload-specific-record-example
client
.upload('./assets/placeholder.md', 'Heroes', 'image', recordId)
.then(result => log('upload-specific-record-example', result))
.catch(error => error),
//#
1000
);
});
//#
const uploads = client =>
Promise.all([uploadImage(client), uploadSpecificImage(client)]).then(
responses => {
store(responses);
return client;
}
);
module.exports = { uploads };