Media Storage Javascript Library for Ricoh API.
You need
Ricoh API Client Credentials (client_id & client_secret)
Ricoh ID (user_id & password)
If you don't have them, please register yourself and your client from THETA Developers Website.
$ npm install ricohapi-mstorage
const MStorage = require('ricohapi-mstorage').MStorage;
const AuthClient = require('ricohapi-mstorage').AuthClient;
const client = new AuthClient('<your_client_id>', '<your_client_secret>');
client.setResourceOwnerCreds('<your_user_id>', '<your_password>');
const mstorage = new MStorage(client);
mstorage.connect()
.then(() => mstorage.upload('./upload_file_path.jpg'))
.then(() => console.log('uploaded'))
.catch(e => console.log(e));
const client = new AuthClient('<your_client_id>', '<your_client_secret>');
client.setResourceOwnerCreds('<your_user_id>', '<your_password>');
const mstorage = new MStorage(<AuthClient object>);
mstorage.connect();
A Promise is returned.
mstorage.upload('./upload_file_path.jpg');
A Promise is returned.
mstorage.downloadTo('<media_id>', './download_file_path.jpg');
A Promise is returned.
mstorage.download('<media_id>', 'blob');
A Promise is returned.
mstorage.list()
.then(list => console.log(list));
mstorage.list({limit: 25, after: '<cursor-id>'})
.then(list => console.log(list));
mstorage.delete('<media_id>');
A Promise is returned.
mstorage.info('<media_id>')
.then(info => console.log(info));
mstorage.meta('<media_id>')
.then(meta => console.log(meta));
mstorage.meta('<media_id>', 'user')
.then(meta => console.log(meta));
mstorage.meta('<media_id>', 'user.<key1>')
.then(meta => console.log(meta));
mstorage.meta('<media_id>', 'exif')
.then(meta => console.log(meta));
mstorage.meta('<media_id>', 'gpano')
.then(meta => console.log(meta));
Existing metadata value for the same key will be overwritten. Up to 10 user metadata can be attached to a media data.
mstorage.addMeta('<media_id>', { 'user.<key1>' : '<value1>', 'user.<key2>' : '<value2>', ...});
A Promise is returned.
mstorage.removeMeta('<media_id>', 'user.<key>');
A Promise is returned.
mstorage.removeMeta('<media_id>', 'user');
A Promise is returned.
return media ids which have all key value pairs
mstorage.list({filter: { 'meta.user.<key1>' : '<value1>', 'meta.user.<key2>' : '<value2>', ...}})
.then(list => console.log(list));