Skip to content

Instantly share code, notes, and snippets.

@eldadfux
Created September 1, 2019 16:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eldadfux/0b10ef3d3b42b35d961e813ecece715e to your computer and use it in GitHub Desktop.
Save eldadfux/0b10ef3d3b42b35d961e813ecece715e to your computer and use it in GitHub Desktop.
Appwrite JS SDK - Upload Example
var appwrite = new window.Appwrite();
appwrite
.setEndpoint('https://localhost/v1')
.setProject('[PROJECT-ID]')
;
var file = document.getElementById('file-input').files[0];
let read = ['*']; // wildecard read access
let write = ['user:self']; // write access only to me
appwrite.storage.createFile(file, read, write)
.then(function (response) {
console.log('file uploaded successfully');
}, function (error) {
console.log(error);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment