How to create an upload (large, ie ~400MB) bytestream service in Vaadin?
In an earlier post from a few minutes ago, I asked a "general" question regarding creating general webservices in vaadin: How can one create webservices in Vaadin 12?
However, one specific unique case that I mainly need to support is the uploading via https of large (eg ~400MB) bytestream objects that would presumably be sent to Vaadin via an https "post" command (with the paylod being provided I presume in raw binary format as a bytestream.) I saw that Vaadin has built-in support for uploading files (which is essentially a post command of a bytestream, I presume?) and then I saw a reference to StreamReceiver here: https://vaadin.com/docs/v12/flow/advanced/tutorial-stream-resources.html
which seems to sound like a custom file importer, but I couldn't find any (simple & more-or-less complete) examples on how to use it. Ideally, a quick few lines of Java to show the "receiving" of the bytestream and a few quick lines (ideally in Java) which "posts" to the receivestream's url would be all that's needed to show how this manual upload of bytes can be accomplished in Vaadin. (In DropWizard & Jersey, I can find such examples reasonably easily, but I'm not sure how to gain that level of control in Vaadin.)
(Very very minor bonus: is there a size limit to the post command? eg, can a bytestream of over say ~4GB be sent and received?)
vaadin
add a comment |
In an earlier post from a few minutes ago, I asked a "general" question regarding creating general webservices in vaadin: How can one create webservices in Vaadin 12?
However, one specific unique case that I mainly need to support is the uploading via https of large (eg ~400MB) bytestream objects that would presumably be sent to Vaadin via an https "post" command (with the paylod being provided I presume in raw binary format as a bytestream.) I saw that Vaadin has built-in support for uploading files (which is essentially a post command of a bytestream, I presume?) and then I saw a reference to StreamReceiver here: https://vaadin.com/docs/v12/flow/advanced/tutorial-stream-resources.html
which seems to sound like a custom file importer, but I couldn't find any (simple & more-or-less complete) examples on how to use it. Ideally, a quick few lines of Java to show the "receiving" of the bytestream and a few quick lines (ideally in Java) which "posts" to the receivestream's url would be all that's needed to show how this manual upload of bytes can be accomplished in Vaadin. (In DropWizard & Jersey, I can find such examples reasonably easily, but I'm not sure how to gain that level of control in Vaadin.)
(Very very minor bonus: is there a size limit to the post command? eg, can a bytestream of over say ~4GB be sent and received?)
vaadin
add a comment |
In an earlier post from a few minutes ago, I asked a "general" question regarding creating general webservices in vaadin: How can one create webservices in Vaadin 12?
However, one specific unique case that I mainly need to support is the uploading via https of large (eg ~400MB) bytestream objects that would presumably be sent to Vaadin via an https "post" command (with the paylod being provided I presume in raw binary format as a bytestream.) I saw that Vaadin has built-in support for uploading files (which is essentially a post command of a bytestream, I presume?) and then I saw a reference to StreamReceiver here: https://vaadin.com/docs/v12/flow/advanced/tutorial-stream-resources.html
which seems to sound like a custom file importer, but I couldn't find any (simple & more-or-less complete) examples on how to use it. Ideally, a quick few lines of Java to show the "receiving" of the bytestream and a few quick lines (ideally in Java) which "posts" to the receivestream's url would be all that's needed to show how this manual upload of bytes can be accomplished in Vaadin. (In DropWizard & Jersey, I can find such examples reasonably easily, but I'm not sure how to gain that level of control in Vaadin.)
(Very very minor bonus: is there a size limit to the post command? eg, can a bytestream of over say ~4GB be sent and received?)
vaadin
In an earlier post from a few minutes ago, I asked a "general" question regarding creating general webservices in vaadin: How can one create webservices in Vaadin 12?
However, one specific unique case that I mainly need to support is the uploading via https of large (eg ~400MB) bytestream objects that would presumably be sent to Vaadin via an https "post" command (with the paylod being provided I presume in raw binary format as a bytestream.) I saw that Vaadin has built-in support for uploading files (which is essentially a post command of a bytestream, I presume?) and then I saw a reference to StreamReceiver here: https://vaadin.com/docs/v12/flow/advanced/tutorial-stream-resources.html
which seems to sound like a custom file importer, but I couldn't find any (simple & more-or-less complete) examples on how to use it. Ideally, a quick few lines of Java to show the "receiving" of the bytestream and a few quick lines (ideally in Java) which "posts" to the receivestream's url would be all that's needed to show how this manual upload of bytes can be accomplished in Vaadin. (In DropWizard & Jersey, I can find such examples reasonably easily, but I'm not sure how to gain that level of control in Vaadin.)
(Very very minor bonus: is there a size limit to the post command? eg, can a bytestream of over say ~4GB be sent and received?)
vaadin
vaadin
asked Jan 2 at 18:21
Jonathan SylvesterJonathan Sylvester
423410
423410
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
In Vaadin the Upload API is optimised for streaming into File (unlike handling the stream as in Servlet and JAX-RS API). One way is to first stream to a temp file and then when the file is fully on the server side, handle the data from temp file.
Alternatively you can use Flow Viritin add-on and a helper class UploadFileHandler, which give you and API where you read the contents from InputStream, in same way as with Servlet API. See a usage example is in this test.
This isn't a first time this is asked and I actually have a more verbose blog draft about this subject. I'll add a link to that once I get that published.
On the server side, either the "Upload to file" or the "Flow add-on" is an acceptable solution for now (with the latter being better since I don't need to store into a temp file). HOWEVER: my understanding is that the "test" code linked above creates a real "UploadFileHandler" which is some sort of GUI? But, how would one programmatically post to this "uploadfilehandle" (ie how can one treat it as a webservice)? (A sample client Java code doing a post to the corresponding Vaadin uploadfilehandler server url would probably answer all questions in one shot, if possible....)
– Jonathan Sylvester
Jan 2 at 19:39
1
Yes, in example user chooses a file to upload and app just counts bytes in the file. If you are sending file/input to your web app from another Java web app, then it makes no sense to do that through Vaadin UI at all. Just use plain servlet API, JAX-RS or similar, that exposes the "url where to post". It can still be in the same web app as the Vaadin UI, just through a different servlet. If the "Java client" also happens to be in the same server, it probably makes no sense at all to use HTTP to move bytes from one place to another, but just some direct Java API.
– mstahv
Jan 2 at 21:11
ok, got it. I'll try the suggestion from stackoverflow.com/questions/54011180/… @mstahv
– Jonathan Sylvester
Jan 3 at 2:02
here's the mentioned blogpost :)
– Cashbee
Jan 7 at 15:51
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54011275%2fhow-to-create-an-upload-large-ie-400mb-bytestream-service-in-vaadin%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
In Vaadin the Upload API is optimised for streaming into File (unlike handling the stream as in Servlet and JAX-RS API). One way is to first stream to a temp file and then when the file is fully on the server side, handle the data from temp file.
Alternatively you can use Flow Viritin add-on and a helper class UploadFileHandler, which give you and API where you read the contents from InputStream, in same way as with Servlet API. See a usage example is in this test.
This isn't a first time this is asked and I actually have a more verbose blog draft about this subject. I'll add a link to that once I get that published.
On the server side, either the "Upload to file" or the "Flow add-on" is an acceptable solution for now (with the latter being better since I don't need to store into a temp file). HOWEVER: my understanding is that the "test" code linked above creates a real "UploadFileHandler" which is some sort of GUI? But, how would one programmatically post to this "uploadfilehandle" (ie how can one treat it as a webservice)? (A sample client Java code doing a post to the corresponding Vaadin uploadfilehandler server url would probably answer all questions in one shot, if possible....)
– Jonathan Sylvester
Jan 2 at 19:39
1
Yes, in example user chooses a file to upload and app just counts bytes in the file. If you are sending file/input to your web app from another Java web app, then it makes no sense to do that through Vaadin UI at all. Just use plain servlet API, JAX-RS or similar, that exposes the "url where to post". It can still be in the same web app as the Vaadin UI, just through a different servlet. If the "Java client" also happens to be in the same server, it probably makes no sense at all to use HTTP to move bytes from one place to another, but just some direct Java API.
– mstahv
Jan 2 at 21:11
ok, got it. I'll try the suggestion from stackoverflow.com/questions/54011180/… @mstahv
– Jonathan Sylvester
Jan 3 at 2:02
here's the mentioned blogpost :)
– Cashbee
Jan 7 at 15:51
add a comment |
In Vaadin the Upload API is optimised for streaming into File (unlike handling the stream as in Servlet and JAX-RS API). One way is to first stream to a temp file and then when the file is fully on the server side, handle the data from temp file.
Alternatively you can use Flow Viritin add-on and a helper class UploadFileHandler, which give you and API where you read the contents from InputStream, in same way as with Servlet API. See a usage example is in this test.
This isn't a first time this is asked and I actually have a more verbose blog draft about this subject. I'll add a link to that once I get that published.
On the server side, either the "Upload to file" or the "Flow add-on" is an acceptable solution for now (with the latter being better since I don't need to store into a temp file). HOWEVER: my understanding is that the "test" code linked above creates a real "UploadFileHandler" which is some sort of GUI? But, how would one programmatically post to this "uploadfilehandle" (ie how can one treat it as a webservice)? (A sample client Java code doing a post to the corresponding Vaadin uploadfilehandler server url would probably answer all questions in one shot, if possible....)
– Jonathan Sylvester
Jan 2 at 19:39
1
Yes, in example user chooses a file to upload and app just counts bytes in the file. If you are sending file/input to your web app from another Java web app, then it makes no sense to do that through Vaadin UI at all. Just use plain servlet API, JAX-RS or similar, that exposes the "url where to post". It can still be in the same web app as the Vaadin UI, just through a different servlet. If the "Java client" also happens to be in the same server, it probably makes no sense at all to use HTTP to move bytes from one place to another, but just some direct Java API.
– mstahv
Jan 2 at 21:11
ok, got it. I'll try the suggestion from stackoverflow.com/questions/54011180/… @mstahv
– Jonathan Sylvester
Jan 3 at 2:02
here's the mentioned blogpost :)
– Cashbee
Jan 7 at 15:51
add a comment |
In Vaadin the Upload API is optimised for streaming into File (unlike handling the stream as in Servlet and JAX-RS API). One way is to first stream to a temp file and then when the file is fully on the server side, handle the data from temp file.
Alternatively you can use Flow Viritin add-on and a helper class UploadFileHandler, which give you and API where you read the contents from InputStream, in same way as with Servlet API. See a usage example is in this test.
This isn't a first time this is asked and I actually have a more verbose blog draft about this subject. I'll add a link to that once I get that published.
In Vaadin the Upload API is optimised for streaming into File (unlike handling the stream as in Servlet and JAX-RS API). One way is to first stream to a temp file and then when the file is fully on the server side, handle the data from temp file.
Alternatively you can use Flow Viritin add-on and a helper class UploadFileHandler, which give you and API where you read the contents from InputStream, in same way as with Servlet API. See a usage example is in this test.
This isn't a first time this is asked and I actually have a more verbose blog draft about this subject. I'll add a link to that once I get that published.
answered Jan 2 at 19:22
mstahvmstahv
1,50177
1,50177
On the server side, either the "Upload to file" or the "Flow add-on" is an acceptable solution for now (with the latter being better since I don't need to store into a temp file). HOWEVER: my understanding is that the "test" code linked above creates a real "UploadFileHandler" which is some sort of GUI? But, how would one programmatically post to this "uploadfilehandle" (ie how can one treat it as a webservice)? (A sample client Java code doing a post to the corresponding Vaadin uploadfilehandler server url would probably answer all questions in one shot, if possible....)
– Jonathan Sylvester
Jan 2 at 19:39
1
Yes, in example user chooses a file to upload and app just counts bytes in the file. If you are sending file/input to your web app from another Java web app, then it makes no sense to do that through Vaadin UI at all. Just use plain servlet API, JAX-RS or similar, that exposes the "url where to post". It can still be in the same web app as the Vaadin UI, just through a different servlet. If the "Java client" also happens to be in the same server, it probably makes no sense at all to use HTTP to move bytes from one place to another, but just some direct Java API.
– mstahv
Jan 2 at 21:11
ok, got it. I'll try the suggestion from stackoverflow.com/questions/54011180/… @mstahv
– Jonathan Sylvester
Jan 3 at 2:02
here's the mentioned blogpost :)
– Cashbee
Jan 7 at 15:51
add a comment |
On the server side, either the "Upload to file" or the "Flow add-on" is an acceptable solution for now (with the latter being better since I don't need to store into a temp file). HOWEVER: my understanding is that the "test" code linked above creates a real "UploadFileHandler" which is some sort of GUI? But, how would one programmatically post to this "uploadfilehandle" (ie how can one treat it as a webservice)? (A sample client Java code doing a post to the corresponding Vaadin uploadfilehandler server url would probably answer all questions in one shot, if possible....)
– Jonathan Sylvester
Jan 2 at 19:39
1
Yes, in example user chooses a file to upload and app just counts bytes in the file. If you are sending file/input to your web app from another Java web app, then it makes no sense to do that through Vaadin UI at all. Just use plain servlet API, JAX-RS or similar, that exposes the "url where to post". It can still be in the same web app as the Vaadin UI, just through a different servlet. If the "Java client" also happens to be in the same server, it probably makes no sense at all to use HTTP to move bytes from one place to another, but just some direct Java API.
– mstahv
Jan 2 at 21:11
ok, got it. I'll try the suggestion from stackoverflow.com/questions/54011180/… @mstahv
– Jonathan Sylvester
Jan 3 at 2:02
here's the mentioned blogpost :)
– Cashbee
Jan 7 at 15:51
On the server side, either the "Upload to file" or the "Flow add-on" is an acceptable solution for now (with the latter being better since I don't need to store into a temp file). HOWEVER: my understanding is that the "test" code linked above creates a real "UploadFileHandler" which is some sort of GUI? But, how would one programmatically post to this "uploadfilehandle" (ie how can one treat it as a webservice)? (A sample client Java code doing a post to the corresponding Vaadin uploadfilehandler server url would probably answer all questions in one shot, if possible....)
– Jonathan Sylvester
Jan 2 at 19:39
On the server side, either the "Upload to file" or the "Flow add-on" is an acceptable solution for now (with the latter being better since I don't need to store into a temp file). HOWEVER: my understanding is that the "test" code linked above creates a real "UploadFileHandler" which is some sort of GUI? But, how would one programmatically post to this "uploadfilehandle" (ie how can one treat it as a webservice)? (A sample client Java code doing a post to the corresponding Vaadin uploadfilehandler server url would probably answer all questions in one shot, if possible....)
– Jonathan Sylvester
Jan 2 at 19:39
1
1
Yes, in example user chooses a file to upload and app just counts bytes in the file. If you are sending file/input to your web app from another Java web app, then it makes no sense to do that through Vaadin UI at all. Just use plain servlet API, JAX-RS or similar, that exposes the "url where to post". It can still be in the same web app as the Vaadin UI, just through a different servlet. If the "Java client" also happens to be in the same server, it probably makes no sense at all to use HTTP to move bytes from one place to another, but just some direct Java API.
– mstahv
Jan 2 at 21:11
Yes, in example user chooses a file to upload and app just counts bytes in the file. If you are sending file/input to your web app from another Java web app, then it makes no sense to do that through Vaadin UI at all. Just use plain servlet API, JAX-RS or similar, that exposes the "url where to post". It can still be in the same web app as the Vaadin UI, just through a different servlet. If the "Java client" also happens to be in the same server, it probably makes no sense at all to use HTTP to move bytes from one place to another, but just some direct Java API.
– mstahv
Jan 2 at 21:11
ok, got it. I'll try the suggestion from stackoverflow.com/questions/54011180/… @mstahv
– Jonathan Sylvester
Jan 3 at 2:02
ok, got it. I'll try the suggestion from stackoverflow.com/questions/54011180/… @mstahv
– Jonathan Sylvester
Jan 3 at 2:02
here's the mentioned blogpost :)
– Cashbee
Jan 7 at 15:51
here's the mentioned blogpost :)
– Cashbee
Jan 7 at 15:51
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54011275%2fhow-to-create-an-upload-large-ie-400mb-bytestream-service-in-vaadin%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown