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
Closed
Labels

Comments

@cgrantcal
Copy link

@cgrantcal cgrantcal 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
Copy link
Member

@lganzzzo lganzzzo 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
Copy link
Author

@cgrantcal cgrantcal 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
Copy link
Member

@lganzzzo lganzzzo commented Mar 4, 2019

Sure,

#include "oatpp-swagger/Types.hpp"

Regards,
Leonid

@cgrantcal
Copy link
Author

@cgrantcal cgrantcal commented Mar 4, 2019

Hey,

Got that working now thank you !

Regards

Conor

@lganzzzo
Copy link
Member

@lganzzzo lganzzzo 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
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants