File tree Expand file tree Collapse file tree 1 file changed +20
-7
lines changed Expand file tree Collapse file tree 1 file changed +20
-7
lines changed Original file line number Diff line number Diff line change @@ -150,14 +150,27 @@ class CoCreateFileSystem {
150
150
sendResponse ( src , 200 , { 'Content-Type' : contentType } )
151
151
152
152
function sendResponse ( src , statusCode , headers ) {
153
- crud . wsManager . emit ( "setBandwidth" , {
154
- type : 'out' ,
155
- data : src ,
156
- organization_id
157
- } ) ;
153
+ try {
154
+ if ( src instanceof Uint8Array ) {
155
+ src = Buffer . from ( src ) ;
156
+ } else if ( Buffer . isBuffer ( src ) ) {
157
+ console . log ( 'buffer' )
158
+ return
159
+ }
158
160
159
- res . writeHead ( statusCode , headers ) ;
160
- return res . end ( src ) ;
161
+ if ( typeof src === 'object' ) {
162
+ src = JSON . stringify ( src ) ;
163
+ }
164
+ crud . wsManager . emit ( "setBandwidth" , {
165
+ type : 'out' ,
166
+ data : src ,
167
+ organization_id
168
+ } ) ;
169
+ res . writeHead ( statusCode , headers ) ;
170
+ return res . end ( src ) ;
171
+ } catch ( error ) {
172
+ console . log ( error )
173
+ }
161
174
}
162
175
163
176
async function getDefaultFile ( fileName ) {
You can’t perform that action at this time.
0 commit comments