File tree Expand file tree Collapse file tree 3 files changed +21
-21
lines changed
uploadEncrypted/encrypt/file Expand file tree Collapse file tree 3 files changed +21
-21
lines changed Original file line number Diff line number Diff line change @@ -50,7 +50,6 @@ export default async <T extends boolean>(
5050 const response = await fetchWithTimeout ( endpoint , {
5151 method : 'POST' ,
5252 body : data ,
53- credentials : 'include' ,
5453 timeout : 7200000 ,
5554 headers : {
5655 Authorization : token ,
@@ -90,7 +89,6 @@ export default async <T extends boolean>(
9089 const response = await fetchWithTimeout ( endpoint , {
9190 method : 'POST' ,
9291 body : data ,
93- credentials : 'include' ,
9492 timeout : 7200000 ,
9593 headers : {
9694 Authorization : token ,
Original file line number Diff line number Diff line change @@ -101,24 +101,26 @@ export default async (
101101 throw new Error ( `HTTP error! status: ${ response . status } ` )
102102 }
103103
104- const reader = response . body ?. getReader ( )
105- let chunks = [ ]
106- while ( true ) {
107- const { done, value } = await reader ! . read ( )
108- if ( done ) {
109- break
110- }
111- chunks . push ( value )
112- }
113-
114- let responseData = new TextDecoder ( 'utf-8' ) . decode (
115- new Uint8Array ( chunks . flatMap ( ( chunk ) => [ ...chunk ] ) )
116- ) as any
117-
118- responseData = JSON . parse ( responseData )
104+ // const reader = response.body?.getReader()
105+ // let chunks = []
106+ // while (true) {
107+ // const { done, value } = await reader!.read()
108+ // if (done) {
109+ // break
110+ // }
111+ // chunks.push(value)
112+ // }
113+
114+ // let responseData = new TextDecoder('utf-8').decode(
115+ // new Uint8Array(chunks.flatMap((chunk) => [...chunk]))
116+ // ) as any
117+ const responseText = await response . text ( )
118+ const jsondata = JSON . parse ( responseText ) as IFileUploadedResponse [ ]
119+
120+ // responseData = JSON.parse(responseData)
119121
120122 const savedKey = await Promise . all (
121- responseData . map ( async ( data : IFileUploadedResponse ) => {
123+ jsondata . map ( async ( data : IFileUploadedResponse ) => {
122124 return saveShards ( publicKey , data . Hash , auth_token , keyMap [ data . Name ] )
123125 } )
124126 )
@@ -139,7 +141,7 @@ export default async (
139141 }
140142 */
141143
142- return { data : responseData }
144+ return { data : jsondata }
143145 } catch ( error : any ) {
144146 return error . message
145147 }
Original file line number Diff line number Diff line change @@ -46,15 +46,15 @@ export default async (
4646
4747 const { error } = await saveShards (
4848 publicKey ,
49- responseData . Hash ,
49+ responseData [ 0 ] . Hash ,
5050 auth_token ,
5151 keyShards
5252 )
5353 if ( error ) {
5454 throw new Error ( 'Error encrypting file' )
5555 }
5656
57- return { data : [ responseData ] }
57+ return { data : responseData }
5858 } catch ( error : any ) {
5959 throw new Error ( error . message )
6060 }
You can’t perform that action at this time.
0 commit comments