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 could I upload file use rest.vertx? #53

Closed
shuitai opened this issue Mar 1, 2020 · 3 comments
Closed

How could I upload file use rest.vertx? #53

shuitai opened this issue Mar 1, 2020 · 3 comments

Comments

@shuitai
Copy link

shuitai commented Mar 1, 2020

No description provided.

@shuitai
Copy link
Author

shuitai commented Mar 1, 2020

How could I upload file with rest.vertx?

@drejc
Copy link
Member

drejc commented Mar 1, 2020

For the top of my head ... best way would be to bind a POST request and then use the @context RoutingContext to get file uploads ...

Something like this:

@POST("upload")
public String fileUpload(@Context RoutingContext context) {
        Set<FileUpload> fileUploadSet = routingContext.fileUploads();
        Iterator<FileUpload> fileUploadIterator = fileUploadSet.iterator();
        while (fileUploadIterator.hasNext()){
          FileUpload fileUpload = fileUploadIterator.next();

          // To get the uploaded file do
          Buffer uploadedFile = vertx.fileSystem().readFileBlocking(fileUpload.uploadedFileName());
...
}

probably you will need to set the correct content type ...

@drejc drejc closed this as completed Mar 1, 2020
@shuitai
Copy link
Author

shuitai commented Mar 3, 2020

Ok, thanks, It is helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants