@@ -65,6 +65,8 @@ import {
65
65
FireFlyGroupResponse ,
66
66
FireFlyBlockchainEventFilter ,
67
67
FireFlyBlockchainEventResponse ,
68
+ FireFlyDataBlobRequest ,
69
+ FireFlyDataBlobRequestDefaults ,
68
70
} from './interfaces' ;
69
71
import { FireFlyWebSocket , FireFlyWebSocketCallback } from './websocket' ;
70
72
import HttpBase , { mapConfig } from './http' ;
@@ -196,25 +198,18 @@ export default class FireFly extends HttpBase {
196
198
197
199
async uploadDataBlob (
198
200
blob : string | Buffer | Readable ,
199
- filename : string ,
201
+ blobOptions ?: FormData . AppendOptions ,
202
+ dataOptions ?: FireFlyDataBlobRequest ,
200
203
) : Promise < FireFlyDataResponse > {
204
+ dataOptions = { ...FireFlyDataBlobRequestDefaults , ...dataOptions } ;
201
205
const formData = new FormData ( ) ;
202
- formData . append ( 'autometa' , 'true' ) ;
203
- formData . append ( 'file' , blob , { filename } ) ;
204
- const response = await this . wrapError (
205
- this . http . post < FireFlyDataResponse > ( '/data' , formData , {
206
- headers : {
207
- ...formData . getHeaders ( ) ,
208
- 'Content-Length' : formData . getLengthSync ( ) ,
209
- } ,
210
- } ) ,
211
- ) ;
212
- return response . data ;
213
- }
214
-
215
- async uploadDataBlobWithFormData (
216
- formData : FormData
217
- ) : Promise < FireFlyDataResponse > {
206
+ for ( const key in dataOptions ) {
207
+ const val = dataOptions [ key as keyof FireFlyDataBlobRequest ] ;
208
+ if ( val !== undefined ) {
209
+ formData . append ( key , val ) ;
210
+ }
211
+ }
212
+ formData . append ( 'file' , blob , blobOptions ) ;
218
213
const response = await this . wrapError (
219
214
this . http . post < FireFlyDataResponse > ( '/data' , formData , {
220
215
headers : {
0 commit comments