@@ -67,44 +67,38 @@ class LoadAgent implements ProviderAgent {
6767 . replace ( '__METADATA__' , encodedMetadata )
6868
6969 const data = encodeText ( replaced )
70-
7170 const landingPageTxId = await this . makePayload ( data , 'text/html' , `${ metadata . name } -landing.html` )
72-
7371 return landingPageTxId
7472 }
7573
7674 async makePayload ( data : Uint8Array , type : string , fileName : string = 'file.dat' ) {
7775 this . init ( )
7876
79- try {
80- const blob = new Blob ( [ data ] , { type } )
81- const formData = new FormData ( )
82- formData . append ( 'file' , blob )
83- formData . append ( 'content_type' , type )
84- formData . append ( 'app_name' , 'Maskbook' )
85-
86- const response = await fetch ( LOAD_UPLOAD_ENDPOINT , {
87- method : 'POST' ,
88- headers : {
89- Authorization : `Bearer ${ process . env . LOAD_KEY } ` ,
90- } ,
91- body : formData ,
92- signal : this . uploadController ?. signal ,
93- } )
94-
95- if ( ! response . ok ) {
96- throw new Error ( `Upload failed: ${ response . statusText } ` )
97- }
77+ const blob = new Blob ( [ data ] , { type } )
78+ const formData = new FormData ( )
79+ formData . append ( 'file' , blob )
80+ formData . append ( 'content_type' , type )
81+ formData . append ( 'app_name' , 'Maskbook' )
82+
83+ const response = await fetch ( LOAD_UPLOAD_ENDPOINT , {
84+ method : 'POST' ,
85+ headers : {
86+ Authorization : `Bearer ${ process . env . LOAD_NETWORK_KEY } ` ,
87+ } ,
88+ body : formData ,
89+ signal : this . uploadController ?. signal ,
90+ } )
9891
99- const result = await response . json ( )
100- if ( ! result . success || ! result . dataitem_id ) {
101- throw new Error ( 'Invalid response from upload service' )
102- }
92+ if ( ! response . ok ) {
93+ throw new Error ( `Upload failed: ${ response . statusText } ` )
94+ }
10395
104- return result . dataitem_id
105- } catch ( error ) {
106- throw error
96+ const result = await response . json ( )
97+ if ( ! result . success || ! result . dataitem_id ) {
98+ throw new Error ( 'Invalid response from upload service' )
10799 }
100+
101+ return result . dataitem_id
108102 }
109103}
110104
0 commit comments