File tree Expand file tree Collapse file tree 6 files changed +79
-0
lines changed
Expand file tree Collapse file tree 6 files changed +79
-0
lines changed Original file line number Diff line number Diff line change @@ -27,4 +27,5 @@ export const messages = {
2727 websocketClosedError : 'The websocket was closed due to an error' ,
2828 websocketClosedUnexpect : 'The websocket was closed unexpectedly' ,
2929 websocketNotReady : 'The websocket is not ready. Run init first' ,
30+ httpNotAvailable : 'IBM Aspera HTTP Gateway is not available' ,
3031} ;
Original file line number Diff line number Diff line change 1+ /**
2+ * HTTP Gateway Core Logic
3+ * - File/Folder picking
4+ * - Starting and testing
5+ *
6+ * @remarks
7+ * Most logic is called directly by Desktop SDK functions
8+ * You may not need to import anything from this file.
9+ */
Original file line number Diff line number Diff line change 1+ import { AsperaSdkTransfer , TransferSpec } from '../models/models' ;
2+ import { asperaSdk } from '../index' ;
3+ import { throwError } from '../helpers/helpers' ;
4+ import { messages } from '../constants/messages' ;
5+
6+ /**
7+ * HTTP Gateway Download Logic
8+ *
9+ * @param transferSpec - TransferSpec for the download
10+ *
11+ * @returns Promise that resolves on success invoke or rejects if unable to start
12+ *
13+ * @remarks
14+ * Most logic is called directly by Desktop SDK functions
15+ * You may not need to import anything from this file.
16+ */
17+ export const httpDownload = ( transferSpec : TransferSpec ) : Promise < AsperaSdkTransfer > => {
18+ if ( ! asperaSdk . supportsHttpGateway ) {
19+ return throwError ( messages . serverNotVerified , { type : 'download' } ) ;
20+ }
21+
22+ return Promise . reject ( 'TODO: HTTP Download Not Ready' ) ;
23+ } ;
Original file line number Diff line number Diff line change 1+ import { httpDownload } from './download' ;
2+ import { httpUpload } from './upload' ;
3+
4+ /**
5+ * HTTP Gateway Exports
6+ *
7+ * @remarks
8+ * Most logic is called directly by Desktop SDK functions
9+ * You may not need to import anything from this file.
10+ */
11+
12+ export {
13+ httpUpload ,
14+ httpDownload ,
15+ } ;
Original file line number Diff line number Diff line change 1+ import { AsperaSdkTransfer , TransferSpec } from '../models/models' ;
2+ import { asperaSdk } from '../index' ;
3+ import { throwError } from '../helpers/helpers' ;
4+ import { messages } from '../constants/messages' ;
5+
6+ /**
7+ * HTTP Gateway Upload Logic
8+ *
9+ * @param transferSpec - TransferSpec for the upload
10+ *
11+ * @returns Promise that resolves on success invoke or rejects if unable to start
12+ *
13+ * @remarks
14+ * Most logic is called directly by Desktop SDK functions
15+ * You may not need to import anything from this file.
16+ */
17+ export const httpUpload = ( transferSpec : TransferSpec ) : Promise < AsperaSdkTransfer > => {
18+ if ( ! asperaSdk . supportsHttpGateway ) {
19+ return throwError ( messages . serverNotVerified , { type : 'upload' } ) ;
20+ }
21+
22+ return Promise . reject ( 'TODO: HTTP Upload Not Ready' ) ;
23+ } ;
Original file line number Diff line number Diff line change @@ -25,6 +25,9 @@ class AsperaSdkGlobals {
2525 sessionId ?: string ;
2626 /** Map of drop zones created by querySelector */
2727 dropZonesCreated : Map < string , { event : string ; callback : ( event : any ) => void } [ ] > = new Map ( ) ;
28+ /** HTTP Gateway URL after successful passing */
29+ httpGatewayUrl ?: string ;
30+
2831
2932 backupLaunchMethod ( url : string ) : void {
3033 window . alert ( messages . loadingProtocol ) ;
@@ -396,4 +399,9 @@ export class AsperaSdk {
396399 get isReady ( ) : boolean {
397400 return this . globals . asperaAppVerified && this . globals . appId !== '' ;
398401 }
402+
403+ /** Indicate that HTTP Gateway is available. */
404+ get supportsHttpGateway ( ) : boolean {
405+ return ! ! this . globals . httpGatewayUrl ;
406+ }
399407}
You can’t perform that action at this time.
0 commit comments