2017-09-04 5 views
1

Wenn ich die binaryMediaTypes ['Bild/jpg', 'Text/html'] für eine API durch nodejs konfigurieren möchten. Was ist die richtige API? Es sieht so aus, als ob das Folgende nicht funktioniert.Aktualisierung aws apigateway binaryMediaTypes mit Javascript SDK

const config = JSON.stringify({ 
      "swagger": "2.0", 
      "info": { 
       "title": this.apiName 
      }, 
      "x-amazon-apigateway-binary-media-types": [ 'image/jpg', 'text/html' ] 
     }); 
     return new Promise((resolve, reject) => { 
      var params = { 
       restApiId: apiId, /* required */ 
       mode: 'merge', 
       body: config 
      }; 
      this.apiGatewaySDK.putRestApi(params, (err, data) => { 
       if (err) { 
        reject(err); 
       } 
       else { 
        resolve('binary set successfully'); 
       } 
      }); 
     }); 

Antwort

0

Wir enden mit updateRestApi(). Bitte beachten Sie den PatchOpertions Teil, ist es sehr unintuitiv (etw aws sdk könnte verbessern?)

 let patchOperationsArray = []; 
     patchOperationsArray.push(
      { 
       op: 'add', 
       path: '/binaryMediaTypes/'+ e.replace("/", "~1") 
      } 
     ); 

     const params = { 
      restApiId: apiId, /* required */ 
      patchOperations:patchOperationsArray 
     }; 
     this.apiGatewaySDK.updateRestApi(params, (err, data) => { 
      if (err) { 
       reject(err); 
      } 
      else { 
       this.serverless.cli.log('API Gateway Configuring: Binary support are set correctly'); 
       resolve('binary set successfully'); 
      } 
     }); 
Verwandte Themen