Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to upload and access a file. [Endpoint documentation]. [Swagger-UI] #47

Closed
cgrantcal opened this issue Mar 4, 2019 · 5 comments

Comments

Projects
None yet
2 participants
@cgrantcal
Copy link

commented Mar 4, 2019

Hey,

Do you have an example of how to add a file upload as part of the endpoint?

Thanks

Conor

@lganzzzo

This comment has been minimized.

Copy link
Member

commented Mar 4, 2019

Hey,

  ENDPOINT_INFO(postFile) {
    info->summary = "Upload file";
    info->addConsumes<oatpp::swagger::Binary>("application/octet-stream");
  }
  ENDPOINT("POST", "/file", postFile,
           BODY_STRING(String, body)) {

     // body contains the file
     // use for ex. body.saveToFile("my_file.png");
    
      return createResponse(Status::CODE_200, "OK");
    }
    
  }

Regards,
Leonid

@cgrantcal

This comment has been minimized.

Copy link
Author

commented Mar 4, 2019

Hey,

Thanks for that !

Could you point me to where Binary is defined:

error: ‘Binary’ is not a member of ‘oatpp::swagger’

Thanks

Conor

@lganzzzo

This comment has been minimized.

Copy link
Member

commented Mar 4, 2019

Sure,

#include "oatpp-swagger/Types.hpp"

Regards,
Leonid

@cgrantcal

This comment has been minimized.

Copy link
Author

commented Mar 4, 2019

Hey,

Got that working now thank you !

Regards

Conor

@cgrantcal cgrantcal closed this Mar 4, 2019

@lganzzzo lganzzzo added the question label Mar 4, 2019

@lganzzzo

This comment has been minimized.

Copy link
Member

commented Mar 4, 2019

You are welcome!
Please let me know in case you have more questions.

Best Regards,
Leonid

@lganzzzo lganzzzo changed the title How to upload and access a file. How to upload and access a file. [Endpoint documentation]. [Swagger-UI] Mar 11, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.