list files on the backend per application
| | |
| | | $.ajax({ |
| | | url: apiRoute('generate_upload_urls'), |
| | | type: "GET", |
| | | dataType: 'json', |
| | | success: function (response) { |
| | | that.uploadEndPoints = that.uploadEndPoints.concat(response); |
| | | completedCallback(); |
| | |
| | | url: endPoint, |
| | | type: "POST", |
| | | data: formdata, |
| | | dataType: 'json', |
| | | processData: false, |
| | | contentType: false, |
| | | success: onSuccess, |
| | |
| | | $.ajax({ |
| | | url: apiRoute(filepath), |
| | | type: "GET", |
| | | dataType: 'json', |
| | | success: onSuccess, |
| | | error: onError |
| | | }); |
| | |
| | | $.ajax({ |
| | | url: apiRoute(filepath), |
| | | type: "DELETE", |
| | | dataType: 'json', |
| | | success: onSuccess, |
| | | error: onError |
| | | }); |
| | |
| | | 'use-strict'; |
| | | |
| | | var cloudFile = new CloudFile(); |
| | | |
| | | var namespacedPath = function (appToken, resource) { |
| | | if (resource[0] !== '/') resource = '/' + resource; |
| | | return appToken + resource; |
| | | }; |
| | | CLOUD_PROVIDERS['CloudFile'] = { |
| | | vendor: 'Humble Bundle Inc', |
| | | listFiles: function (options, onSuccess, onError) { |
| | | cloudFile.read(namespacedPath(options.applicationToken, '/'), onSuccess, function (err) { |
| | | if (err.status == 404) { // not a real directory |
| | | onSuccess([]); |
| | | allFiles: function (options, onSuccess, onError) { |
| | | cloudFile.read( |
| | | namespacedPath(options.applicationToken, '/'), |
| | | onSuccess, |
| | | onError |
| | | ) |
| | | }, |
| | | read: function (options, path, onSuccess, onError) { |
| | | cloudFile.read( |
| | | namespacedPath(options.applicationToken, path), |
| | | onSuccess, |
| | | function (err) { |
| | | if (err.status == 404) { |
| | | // path doesn't exist |
| | | onSuccess([]); |
| | | } else { |
| | | onError(err); |
| | | } |
| | | } |
| | | }); |
| | | ); |
| | | }, |
| | | downloadFile: function (options, url, onSuccess, onError) { |
| | | cloudFile.read(namespacedPath(options.applicationToken, url), onSuccess, onError) |
| | | }, |
| | | uploadFile: function (options, fileinfo, data, onSuccess, onError) { |
| | | write: function (options, fileinfo, data, onSuccess, onError) { |
| | | cloudFile.write(namespacedPath(options.applicationToken, fileinfo.path), data, onSuccess, onError) |
| | | }, |
| | | removeFile: function (options, fileinfo, onSuccess, onError) { |
| | | rm: function (options, fileinfo, onSuccess, onError) { |
| | | cloudFile.rm(namespacedPath(options.applicationToken, fileinfo.path), onSuccess, onError); |
| | | } |
| | | }; |