Predix_Logo
  • Categories
    • Questions
    • Predix | Updates
      • Pricing
      • Product
    • Deloitte - Private
    • How-To
    • Accenture-Private
  • Explore
    • Topics
    • Questions
    • Articles
    • Feedback or Feature Requests
  • Sign in
  • Home /
  • Questions /
avatar image
1
Question by shashanksis@microland.com · Oct 04, 2017 at 12:16 PM · uaapredix-uipredix-starter-kitexpress

Not able to post multipart file data with express server in predix webapp starter

i am using webcomponent vaadin upload to upload files using multipart when i am using

   <vaadin-upload id="calibration"
     target="https://blobstore-uploadpredix.run.aws-usw02-pr.ice.predix.io/idp/api/v1/upload?gyroname=Eg0123">
       <iron-icon slot="drop-label-icon" icon="description"></iron-icon>
       <span slot="drop-label">Drop your calibration file</span>
     </vaadin-upload>

i am able to hit directly to endpoint i am able to upload and hit the server. but when i am redirecting this api to express for appending some token i am not able to hit the api i kept on getting 500 internal server app.js if (config.postCalibration && config.postCalibration.indexOf('https') === 0) {

     app.post('/idp/api/v1/upload', passport.authenticate('main', {
         noredirect: true
       }),
       // if calling a secure microservice, you can use this middleware to add a client token.
       proxy.addAccessTokenMiddleware,
       proxy.customProxyMiddleware('/idp/api/v1/upload', config.postCalibration, '/data/idp/api/v1/upload')
     );
   }

@Greg Stroup can you please help i am getting 500 server error while trying to hit multipart file from express server?

Comment
Add comment
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

  • Sort: 
avatar image
0

Answer by Greg Stroup · Oct 09, 2017 at 08:57 AM

I haven't used the vaadin-upload component before, but it looks like you are bypassing the Express server, and going directly to the blobstore service from your browser application. Your browser should post to /idp/api/v1/upload. Then an Express middleware function will add the token for you.

Comment
Add comment · Show 2 · Share
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image shashanksis@microland.com · Oct 09, 2017 at 07:12 PM 0
Share

Hi @Greg Stroup i removed the vaadin upload and using iron form to post data to express js, but multipart request is not going through express when i use

app.post('/idp/api/v1/upload', passport.authenticate('main', { noredirect: true }), // if calling a secure microservice, you can use this middleware to add a client token. proxy.addAccessTokenMiddleware, proxy.customProxyMiddleware('/idp/api/v1/upload', config.postCalibration, '/data/idp/api/v1/upload') ); }

can you please let me know what changes has to be made in middleware function in app.js for a proxy of multipart request?

avatar image Greg Stroup ♦ shashanksis@microland.com · Oct 10, 2017 at 02:25 PM 0
Share

Right now, the proxy.js file only supports application/json. You'll need to write a little code to use a different content type, like multipart. Here's where the content-type is set right now...

https://github.com/PredixDev/predix-webapp-starter/blob/master/server/routes/proxy.js#L88

Follow this Question

Answers Answers and Comments

128 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to send access token from predix ui with the rest api's? 2 Answers

How to handle multipart request in predix webapp starter? 3 Answers

UAA not redirecting to the appilcation 1 Answer

predix ui and uaa 2 Answers

Predix-Webapp-Starter modification for displaying my own Time Series Info 1 Answer

GE Monogram
  • Legal
  • Cookies
  • Forum Terms
  • Contact Us
  • Copyright © 2017 General Electric Company. All rights reserved.


Enterprise
Social Q&A

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Create an article
  • Submit your feedback or feature request
  • Categories
  • Questions
  • Predix | Updates
    • Pricing
    • Product
  • Deloitte - Private
  • How-To
  • Accenture-Private
  • Explore
  • Topics
  • Questions
  • Articles
  • Feedback or Feature Requests