in examples/demo-app/src/cloud-providers/dropbox/dropbox-provider.js [213:253]
async uploadMap({mapData, options = {}}) {
const {isPublic} = options;
const {map, thumbnail} = mapData;
// generate file name if is not provided
const name = map.info && map.info.title;
const fileName = `${name}.json`;
const fileContent = map;
// FileWriteMode: Selects what to do if the file already exists.
// Always overwrite if sharing
const mode = options.overwrite || isPublic ? 'overwrite' : 'add';
let metadata;
try {
metadata = await this._dropbox.filesUpload({
path: `${this._path}/${fileName}`,
contents: JSON.stringify(fileContent),
mode
});
} catch (err) {
if (isConfigFile(err)) {
throw this.getFileConflictError();
}
}
// save a thumbnail image
thumbnail &&
(await this._dropbox.filesUpload({
path: `${this._path}/${fileName}`.replace(/\.json$/, '.png'),
contents: thumbnail,
mode
}));
// keep on create shareUrl
if (isPublic) {
return await this._shareFile(metadata);
}
// save private map save map url
this._loadParam = {path: metadata.path_lower};
return this._loadParam;
}