@@ -7,6 +7,8 @@ const ConnectionConfig = require('./connectionConfig')
77const WOQL = require ( './woql' )
88const WOQLQuery = require ( './query/woqlBuilder' )
99const { default : axios } = require ( 'axios' )
10+ const FormData = require ( 'form-data' ) ;
11+ const fs = require ( 'fs' ) ;
1012
1113/**
1214 * @license Apache Version 2
@@ -555,13 +557,30 @@ WOQLClient.prototype.query = function(woql, commitMsg, allWitnesses, lastDataVer
555557 if ( woql && woql . json && ( ! woql . containsUpdate ( ) || commitMsg ) ) {
556558 let doql = woql . containsUpdate ( ) ? this . generateCommitInfo ( commitMsg ) : { }
557559 doql . query = woql . json ( )
560+
561+ let postBody ;
562+
563+ if ( doql . query . resource . source . post ) {
564+ const fileName = doql . query . resource . source . post . split ( '/' ) . pop ( ) ;
565+
566+ const formData = new FormData ( ) ;
567+ formData . append ( 'file' , fs . createReadStream ( doql . query . resource . source . post ) ) ;
568+ doql . query . resource . source . post = fileName ;
569+ formData . append ( 'payload' , Buffer . from ( JSON . stringify ( doql ) ) , { filename : 'body.json' , contentType : 'application/json' } ) ;
570+ this . customHeaders ( formData . getHeaders ( ) ) ;
571+
572+ postBody = formData ;
573+ } else {
574+ postBody = doql ;
575+ }
576+
558577 if ( allWitnesses ) doql . all_witnesses = true
559578
560579 if ( typeof lastDataVersion === 'string' && lastDataVersion !== '' ) {
561580 this . customHeaders ( { 'TerminusDB-Data-Version' : lastDataVersion } )
562581 }
563582
564- return this . dispatch ( CONST . WOQL_QUERY , this . connectionConfig . queryURL ( ) , doql , getDataVersion )
583+ return this . dispatch ( CONST . WOQL_QUERY , this . connectionConfig . queryURL ( ) , postBody , getDataVersion )
565584 }
566585 let errmsg = `WOQL query parameter error`
567586 if ( woql && woql . json && woql . containsUpdate ( ) && ! commitMsg ) {
0 commit comments