@@ -272,6 +272,15 @@ export const cleanTrashForRemote = (fs) => {
272
272
} )
273
273
}
274
274
275
+ /**
276
+ * Get a downloadable url for an rclone object
277
+ * @param ipAddress {string} IP address of running rclone instance
278
+ * @param fsInfo {object} FsInfo of the remote
279
+ * @param remoteName {string} name of the remote
280
+ * @param remotePath {string} path of the file. Relative to remoteName
281
+ * @param item {string} item details
282
+ * @returns {string } url which can be used to download the required file.
283
+ */
275
284
export const getDownloadURLForFile = ( ipAddress , fsInfo , remoteName , remotePath , item ) => {
276
285
let downloadURL = "" ;
277
286
@@ -285,3 +294,49 @@ export const getDownloadURLForFile = (ipAddress, fsInfo, remoteName, remotePath,
285
294
}
286
295
return downloadURL ;
287
296
}
297
+
298
+ /**
299
+ * Send a backend command and return the result.
300
+ * @param command {string} string with the command name
301
+ * @param arg {array<string>} remote name string eg "drive:"
302
+ * @param opt {$ObjMap} list of arguments for the backend command
303
+ * @param fs {string} remote name string eg "drive:"
304
+ * @returns {Promise<$ObjMap> }
305
+ */
306
+ export const backendCommand = ( command , arg , opt , fs ) => {
307
+ if ( ! fs ) fs = "." ;
308
+
309
+ return new Promise ( ( resolve , reject ) => {
310
+ if ( ! command || ! arg || ! opt ) throw new Error ( `One or more invalid arguments {${ command } },{${ arg } } {${ opt } } {${ fs } }` )
311
+ axiosInstance . post ( urls . backendCommand , {
312
+ command,
313
+ arg,
314
+ opt,
315
+ fs
316
+ } ) . then ( res => {
317
+ resolve ( res . data ) ;
318
+ } , error => {
319
+ reject ( error ) ;
320
+ } )
321
+ } ) ;
322
+ }
323
+
324
+ /**
325
+ * Send a backend command and return the result.
326
+ * @param arg {array<string>} remote name string eg "drive:"
327
+ * @param opt {$ObjMap} list of arguments for the backend command
328
+ * @returns {Promise<$ObjMap> }
329
+ */
330
+ export const coreCommand = ( arg , opt ) => {
331
+ return new Promise ( ( resolve , reject ) => {
332
+ if ( ! arg || ! opt ) throw new Error ( `One or more invalid arguments ,{${ arg } } {${ opt } }` )
333
+ axiosInstance . post ( urls . coreCommand , {
334
+ arg,
335
+ opt,
336
+ } ) . then ( res => {
337
+ resolve ( res . data ) ;
338
+ } , error => {
339
+ reject ( error ) ;
340
+ } )
341
+ } ) ;
342
+ }
0 commit comments