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?)
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.
Related
Google Speech API via gRPC recognizes first few words only. Tested using several short (<10s) audio files in several (wav, flac) formats.
I am trying to get Google's speech API to work with Delphi using gRPC. (Calling the Speech API from Delphi using JSON works OK, but does not support streaming)
As Google does not support Delphi as gRPC client, I use Grijjy's protocolbuffers for Serializing/Deserializing audio request/response, and Grijjy's scalable sockets for the http/2 request.
As I think the code is too large to share here, I created a MVCE. A zip file containing source code (Delphi 10.3), executable and audio file can be found here. The audio file contains the text "How old is the Brooklyn Bridge", which is flawlessly recognized when calling the Speech API via JSON.
To run the executable, only a Google API key is necessary. Necessary support file nghttp2.dll is included. After sending a request, a messagebox is displayed containing the deserialized response. I checked this is the complete Google response by checking response data size. The response only shows "how old", where I would have expected a full recognized sentence. No errors are returned, confidence factor is also returned.
To compile the source code, Grijjy's code as mentioned above must downloaded from Github and the folder(s) containing the downloaded code made available to the Delphi project.
Also, for Google to accept the request, in grijjy.http, line 1215 needs to modified from
FInternalHeaders.AddOrSet('host', FURI.Host);
to
FInternalHeaders.AddOrSet(':authority', FURI.Host);
(I failed to create a pull request for this earlier today, will try again later)
During my debugging efforts, I also checked response headers (200 OK), also tried other files (same issue).
For now, I do not know how to continue. Any ideas regarding how to get find the cause (or even better, a solution:-) of this issue would be highly appreciated.
I'm running an IIS web site (built using ASP.NET/MVC) that among other things collects files from multiple agents that anonymously upload the files via BITS.
I need to make sure that only files uploaded from known sources as well as matching certain predefined file name pattern will be accepted by IIS. All other BITS upload attempts must be cancelled.
As I understand, BITS uses an ad hoc protocol over HTTP 1.1 using "BITS_POST" verb. So, ideally, I'd like to hook into IIS, analyze a BITS_POST request info and if it does not satisfy my pre-conditions, drop the request.
I've tried to create and register a filter implementing IActionFilter.OnActionExecuting, but it seems that my filter does not receive BITS_POST requests.
I'd be glad to hear if somebody have implemented similar BITS related solutions and how this was done. Anyway, other ideas are welcome too.
Regards,
Natan
I have never worked with BITS, frankly i dont know what is it.
What i usually do is such situations is implement an HTTP module. On its begin request event, you can iterate through incoming HTTP request data and decide to stop processing the request if data is not complying with requirements. You have full access to HttpContext.Current.Request object from HTTP module code.
With HTTP modules, you can execute .NET code even before entering the ASP.NET pipeline.
What's the correct way of transferring media (photos or movies) using Worklight Adapters?
I sent a photo via the adapter and got the error: form too large, exceed the maximum size...
I read I need to change the form size through the Jetty
but the server I'll deploy the app won't be a jetty so what shell i do?
Thanks!
Please see topic Uploading large (and binary) files to Worklight adapter.
Basically, Worklight does not have the equivalent to an HTTP POST mechanism that allows you to transfer arbitrarily large chunked data. For large files of unknown sizes (photos, video, audio) you'll need to upload the file to the server outside the Worklight adapter framework. For example you could simply post it to a web server you have configured. In my case (in the above referenced answer) I needed to create an entire client-server mechanism to negotiate a port and key, start listening on that port, then accept requests and ensure the posting client passes the key as authorization to transfer the secure data.
Hopefully IBM will provide a formal service for this in a future release.
Adapters do not work with html forms, they work with data.
You will need to convert your image to base64 and submit as a adapter invocation parameter.
Having more information regarding what exactly you're trying to achieve might be helpful.
I've a file I want to send to the ebay system to support the LMS.
All the samples I've found include the use of the API, but the environment I'm working in doesn't have the ability to use it (the api).
So I'm forced to send the file with an HTTP post. But the doc's seem lacking.
Has anyone constructed/found an example of a HTTP post that will send a given file.
EDIT:
Oh.. what I see in the samples I have found is an area that seems it's supposed to have the data, but in the sample, there's nothing I'd consider real data.
Are you talking about the file transfer service or the bulk upload service? Don't you just generate an xml document and post the url like in this example:
http://developer.ebay.com/DevZone/file-transfer/CallRef/uploadFile.html#Samples
I'm working a custom SpringSecurityFilter for my Grails application and I'm trying to use the commons upload library to process the request. I'm able to process the request in the filter but once it gets to my controller, none of the values are available.
Can the HttpRequest only be processed once by the upload library? I'm guessing it's cleaning up the temp files. Is there a way to keep them around so they can be processed again at the controller level?
I need to interrogate a form parameter for the security (due to the client I can't add it to the http headers) but once I get the value, it seems to wipe the request for further processing.
Yes. A Request can only be parsed once.
I saw this answer on Apache's FAQ page for FileUpload.
Question: Why is parseRequest() returning no items?
Answer: "This most commonly happens when the request has already been parsed, or processed in some other way. Since the input stream has aleady been consumed by that earlier process, it is no longer available for parsing by Commons FileUpload."
Reference: http://commons.apache.org/fileupload/faq.html