All: Fixes : Handle restricted_content error for Dropbox

pull/811/head
Laurent Cozic 2018-09-16 19:49:07 +01:00
parent 4e8372174b
commit e7a9f630ec
1 changed files with 14 additions and 6 deletions
ReactNativeClient/lib

View File

@ -159,12 +159,20 @@ class FileApiDriverDropbox {
// See https://github.com/facebook/react-native/issues/14445#issuecomment-352965210 // See https://github.com/facebook/react-native/issues/14445#issuecomment-352965210
if (typeof content === 'string') content = shim.Buffer.from(content, 'utf8') if (typeof content === 'string') content = shim.Buffer.from(content, 'utf8')
try {
await this.api().exec('POST', 'files/upload', content, { await this.api().exec('POST', 'files/upload', content, {
'Dropbox-API-Arg': JSON.stringify({ 'Dropbox-API-Arg': JSON.stringify({
path: this.makePath_(path), path: this.makePath_(path),
mode: 'overwrite', mode: 'overwrite',
mute: true, // Don't send a notification to user since there can be many of these updates mute: true, // Don't send a notification to user since there can be many of these updates
})}, options); })}, options);
} catch (error) {
if (this.hasErrorCode_(error, 'restricted_content')) {
throw new JoplinError('Cannot upload because content is restricted by Dropbox', 'rejectedByTarget');
} else {
throw error;
}
}
} }
async delete(path) { async delete(path) {