Welcome Guest Search | Active Topics | Sign In | Register

Getting byte stream from download in eo.WebBrowser Options
S-H
Posted: Thursday, February 13, 2020 10:35:18 AM
Rank: Newbie
Groups: Member

Joined: 3/2/2017
Posts: 8
Hi, I have studied the WebBrowser documentation but I have not found this... is it possible to get the byte stream from downloading in eo.WebBrowser?

Thus, instead of that a user's download action shows a file picker dialogue to point out where the file is to be locally stored on disk, I want the file contents' byte stream to be sent to my own local .Net code, preferably without intermediate disk storage.

The reason is that we have high secrecy customers that do not want files ending up laying around on PC:s' C-disks etc. Instead, my idea is to build a specific "web browser" for them to install, that automatically sends to file contents to our safe service in a REST call.

This will also be more user-friendly since the users do not need to first download to disk and then upload to our web application.

Another reason for this need is that these customers use standard applications that expose no API:s for acquiring a file, only web file download.

(I am aware that Chromium might use local file caching, but these web applications set cache rules so that the risk of remaining files is low.)

Best regards
Sven
eo_support
Posted: Thursday, February 13, 2020 10:43:29 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,071
Hi,

No. This is not possible through the browser engine for regular download. The browser engine always write the download to disk first.

There are a number of possible solutions for your case. One way is to do the download completely outside of the browser engine entirely on the C# side. The other way is to use JavaScript to fetch chunks through the browser engine and then pass it to C# side for assembling/storage. For the second option, you would definitely need to change your server side code accordingly.

Thanks!
S-H
Posted: Thursday, February 13, 2020 11:01:27 AM
Rank: Newbie
Groups: Member

Joined: 3/2/2017
Posts: 8
Thanks for the answer!

Too bad. OK, if I accept that the file gets downloaded to intermediate disk storage for a short while, would this work:

1. It seems as if I can intercept the "Save as" dialogue and create a temporary guid file name etc for the download to happen, without the user seeing any disturbing dialogues.

2. Is there some sort of after-download-event etc? There I could (in local .Net code) read the disk file and send it via REST to us, and then directly delete the file from local disk.
(There is of course a tiny risk that the program or PC crashes etc so that the file remains on disk, but it would be much, much better than today's manual-download-and-upload-to-us.)

3. Then we could show some message to the user that the file is safely sent to our service.

/Sven
eo_support
Posted: Thursday, February 13, 2020 2:56:30 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,071
Hi,

Yes. You would handle BeforeDownload and DownloadCompleted event:

https://www.essentialobjects.com/doc/webbrowser/customize/download.aspx

Thanks!
S-H
Posted: Friday, February 14, 2020 6:36:31 AM
Rank: Newbie
Groups: Member

Joined: 3/2/2017
Posts: 8
Thank you, excellent.

Now, we have about the same problem but in the other direction: Automatically uploading files TO the standard application, since we have no power over that web application, and it does not include any API:s.

However, I don't seem to find any UploadItem class comparable to DownloadItem.

I can see that I could intercept the FileDialog, so I guess that in .Net code I could call our API to get the file contents, save the file temporarily to disk and specify that filename in FileDialogEventArgs's Continue.

But for the aforementioned reasons I then would very much like to delete the temporary file once the upload is completed. Is there any event for that?

I guess one problem could be that we don't know if the standard web application uses normal upload or some AJAX type of upload, that maybe those work differently...
eo_support
Posted: Friday, February 14, 2020 8:06:26 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,071
Hi,

I think you are chasing on the wrong direction --- a WebBrowser control is primarily for displaying contents, it's not for automation. Particularly for file upload, the browser engine has many layer of security checks all over to make sure it can NOT be automated --- otherwise everyone can write a web page to automatically fetch a file from your local system and all they need to do is to lure you to visit that page, then they will automatically fetch some super important files on your computer and upload it to their server. Obviously this can not be allowed.

If you just want to upload a file, you can do it on .NET side entirely without having to go through the WebBrowser control at all. It's possible that you may need additional information from the WebBrowser control to complete the upload successfully. For example, your server may need an authentication cookie for authentication purpose, those are areas where you would work with WebBrowser control, not the upload itself.

Thanks!
S-H
Posted: Saturday, February 15, 2020 6:01:58 AM
Rank: Newbie
Groups: Member

Joined: 3/2/2017
Posts: 8
Thank you!

I agree, malicious use of this scenario could be possible.

If we would do this, we would have to package it in a small application that our customers' IT department trusts and installs in these client machines. So it should not be something that these users are supposed to get themselves somewhere on the Internet and install.
eo_support
Posted: Saturday, February 15, 2020 10:03:19 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,071
You can, but you won't be doing this through the browser engine. The browser engine won't allow this kind of back doors. So you will have to do it through your own code. The browser engine can help you get other things you need, but it won't do the upload without user interaction for you.


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.