-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add is ready poll in
uploadFromUrl
(#238)
* add is ready poll * use is ready poll in from url and base uploads
- Loading branch information
Showing
6 changed files
with
200 additions
and
190 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import info from '../api/info' | ||
import { poll } from './poll' | ||
import { FileInfo } from '../api/types' | ||
import CancelController from './CancelController' | ||
|
||
type ArgsIsReadyPool = { | ||
file: string | ||
publicKey: string | ||
baseURL?: string | ||
source?: string | ||
integration?: string | ||
retryThrottledRequestMaxTimes?: number | ||
onProgress?: (args: { value: number }) => void | ||
cancel?: CancelController | ||
} | ||
|
||
function isReadyPoll({ | ||
file, | ||
publicKey, | ||
baseURL, | ||
source, | ||
integration, | ||
retryThrottledRequestMaxTimes, | ||
cancel, | ||
onProgress | ||
}: ArgsIsReadyPool): FileInfo | PromiseLike<FileInfo> { | ||
return poll<FileInfo>({ | ||
check: cancel => | ||
info(file, { | ||
publicKey, | ||
baseURL, | ||
cancel, | ||
source, | ||
integration, | ||
retryThrottledRequestMaxTimes | ||
}).then(response => { | ||
if (response.isReady) { | ||
return response | ||
} | ||
onProgress && onProgress({ value: 1 }) | ||
return false | ||
}), | ||
cancel | ||
}) | ||
} | ||
|
||
export { isReadyPoll } |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.