Skip to content

Commit

Permalink
fix: add is ready pool for mulipart upload (#254)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeetiss authored Apr 20, 2020
1 parent e2330bb commit fe7ca2a
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/uploadFile/uploadMultipart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import CancelController from '../tools/CancelController'
import runWithConcurrency from '../tools/runWithConcurrency'
import { UploadcareFile } from '../tools/UploadcareFile'
import { getFileSize } from '../tools/isMultipart'
import { isReadyPoll } from '../tools/isReadyPoll'
import retrier from '../tools/retry'

/* Types */
Expand Down Expand Up @@ -167,6 +168,22 @@ const uploadMultipart = (
retryThrottledRequestMaxTimes
})
)
.then(fileInfo => {
if (fileInfo.isReady) {
return fileInfo
} else {
return isReadyPoll({
file: fileInfo.uuid,
publicKey,
baseURL,
source,
integration,
retryThrottledRequestMaxTimes,
onProgress,
cancel
})
}
})
.then(fileInfo => new UploadcareFile(fileInfo, { baseCDN }))
}

Expand Down

0 comments on commit fe7ca2a

Please sign in to comment.