Skip to content

Commit 3a9ba4f

Browse files
authored
fix: download provider selector (#19)
1 parent 1d3014c commit 3a9ba4f

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

src/actions/download.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,7 @@ const THREE_HOURS = 1000 * 60 * 60 * 3;
1515
* @return {Promise}
1616
*/
1717
module.exports = function getDownloadURL(opts) {
18-
const provider = this.provider('download', opts);
19-
2018
const { uploadId, username } = opts;
21-
const { cname, expire } = provider;
22-
2319
const key = `${FILES_DATA}:${uploadId}`;
2420

2521
return Promise
@@ -28,7 +24,9 @@ module.exports = function getDownloadURL(opts) {
2824
.then(isProcessed)
2925
.then(data => {
3026
// parse file data
27+
const provider = this.provider('download', data);
3128
const { name, files } = data;
29+
const { cname, expire } = provider;
3230

3331
// check status and if we have public link available - use it
3432
let urls;
@@ -46,6 +44,7 @@ module.exports = function getDownloadURL(opts) {
4644
hasAccess(username)(data);
4745

4846
// signed URL settings
47+
4948
const settings = {
5049
action: 'read',
5150
// 3 hours

src/custom/cappasity-select-bucket.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// this file contains logic for selecting transport for uploading
22
// input is upload opts
3+
const is = require('is');
34
const findIndex = require('lodash/findIndex');
45
const { FILES_BUCKET_FIELD, FILES_TEMP_FIELD } = require('../constant.js');
56

@@ -45,7 +46,7 @@ const ACTION_TO_SELECTOR = {
4546
// fn for selection
4647
function selectTransport(action, opts) {
4748
const thunk = ACTION_TO_SELECTOR[action];
48-
if (!thunk) {
49+
if (!is.fn(thunk)) {
4950
throw new Error(`${action} selector not defined`);
5051
}
5152

0 commit comments

Comments
 (0)