2020-01-30 20:58:49 +00:00
|
|
|
const sdk = require('node-appwrite');
|
2020-02-15 17:53:12 +00:00
|
|
|
const fs = require('fs');
|
2020-01-30 20:58:49 +00:00
|
|
|
|
|
|
|
|
// Init SDK
|
|
|
|
|
let client = new sdk.Client();
|
|
|
|
|
|
|
|
|
|
let storage = new sdk.Storage(client);
|
|
|
|
|
|
|
|
|
|
client
|
2020-05-28 04:41:25 +00:00
|
|
|
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
|
2020-02-15 18:22:34 +00:00
|
|
|
.setProject('5df5acd0d48c2') // Your project ID
|
|
|
|
|
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
|
2020-01-30 20:58:49 +00:00
|
|
|
;
|
|
|
|
|
|
2020-02-14 06:28:54 +00:00
|
|
|
let promise = storage.createFile(fs.createReadStream(__dirname + '/file.png')), [], []);
|
2020-01-30 20:58:49 +00:00
|
|
|
|
|
|
|
|
promise.then(function (response) {
|
|
|
|
|
console.log(response);
|
|
|
|
|
}, function (error) {
|
|
|
|
|
console.log(error);
|
|
|
|
|
});
|