File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change
1
+ /**
2
+ * Warning: This script uses an experimental alpha feature
3
+ *
4
+ * Upload a local media file
5
+ *
6
+ * To run me:
7
+ *
8
+ * 1. Replace "YOUR_ADMIN_API_KEY" below with your admin key (and edit the URL if you're not using localhost)
9
+ * 2. Make sure the example you want to test is uncommented
10
+ * 3. Run `node upload-file.js ./sample_document.pdf some-ID-123`
11
+ * ^ script name ^ path to file ^ reference
12
+ */
13
+
14
+ // The admin API client is the easiest way to use the API
15
+ const GhostAdminAPI = require ( '@tryghost/admin-api' ) ;
16
+ const path = require ( 'path' ) ;
17
+
18
+ // Configure the client
19
+ const api = new GhostAdminAPI ( {
20
+ url : 'http://localhost:2368' ,
21
+ // @TODO : edit your key here
22
+ key : 'YOUR_ADMIN_API_KEY_HERE' ,
23
+ version : 'canary'
24
+ } ) ;
25
+
26
+ const file = process . argv [ 2 ] ;
27
+ const ref = process . argv [ 3 ] ;
28
+
29
+ api . files . upload ( {
30
+ file : path . join ( __dirname , file ) ,
31
+ ref
32
+ } )
33
+ . then ( response => console . log ( response ) )
34
+ . catch ( error => console . error ( error ) ) ;
You can’t perform that action at this time.
0 commit comments