Sending/Streaming large files in an automated fashion via http (and avoiding the firewall) - http

I've created a VBScript that collects event data from a Windows machine and stores it in a CSV file.
I want to upload this data via http back to our office server, but the file sizes are quite large. So i looked at some multipart/streaming solutions, but im told that if i initiate these file uploads programmatically, any http proxies or firewalls will block/deny the requests?
Can anyone confirm if that is indeed true, and what would a way to get around that?
I need to have a programmed solution in place to upload the files, and i cant rely on an end-user to manually invoke the upload (as i understand that would get around the firewall/http proxy issue)
Can anyone help or advise on this matter?
I found this previous answer, but wasnt sure if it applies to me? Is this solution programmatically imitating a browser file upload request, or will it ask the user to 'pick the file'?
Upload files with HTTPWebrequest (multipart/form-data)

To know if it will be blocked you would have to try it, if you have some code you tried we could help you with errors you encounter. Some general advise:
Compress the CSV before sending, the gains could be impressive.
Try to use a synchronising service like dropbox, it passes some firewalls if properly configured.
If security is not a big issue and the FTP port is open in the firewall you could try to transfer it with FTP, there are vbs scripts that do this but you will have to fiddle until it works.
If abolutely nothing else works you can use a regular browser and have a script interact with it. You could try it with the AutoIt ActiveX, don't try this with sendkeys.
If you are wanting to learn, try another language, it would be for more easy to do this in a language like Ruby which has far more options to use internet communication and handle proxy's etc.

Related

Is there any way to run code on the client in ASP.NET?

As the title says, how would I go about doing this? I want to check a value stored in a file.
This is impossible and has nothing to do with ASP .NET. The browser is responsible for rendering the page to the client, and browsers, for obvious reasons (security), don't have access to the user's file system. The only thing a browser can do, is read cookies (essentially text files) sent to the user from the same domain the website belongs to.
HTML5 has a new feature called local storage but you still won't be able to access ANY file on the user's computer.
Using Javascript with ASP.Net applications can work quite well, I've done it for a couple of sites I've done. If you just want to run some code on the client when a checkbox is ticked for instance, try this...
replace the myFunction() portion out with whatever client side code you want to write.
If you unfamiliar with Javascript as a language, check this out... http://www.w3schools.com/js/default.asp
You can do that using ActiveX control or SilverLight
Some are saying it's not possible, and that is true for the Internet. However, I have done this before on an Intranet system. The server knew the users computer name and could access a local configuration file, no ActiveX, no Silverlight.

Can I make the download dialog box appear without "save" option?

I have a hyperlink to an executable like so: Run Now
I'm trying to make the download dialog box appear without the save function as it is to only run only on the user's computer.
Is there any way to manipulate the file download dialog box?
FYI: Running on Windows Server '03' - IIS.
Please no suggestions for a WCF program.
Okay I found it for anyone stumbling upon this conundrum in the future.
Add the following tag to your head section: <meta name="DownloadOptions" content="nosave" /> and the file download dialog box will not display the "save" option.
For the user to not open/run but save replace "nosave" with "noopen"
Not unless you have some control over a user's machine. If your application can run on limited resources, you might want to consider doing it in Silverlight.
IMO, having a website launching an executable is a pretty bad idea.... even worst if that website is open to the general public (not on intranet). I don't know what that app is doing but it sure is NOT, 1) cross browser, 2) cross platform, and 3) safe for your users.
If you are on intranet, you might get away with giving the full server path (on a shared drive) to the executable and change security settings on your in-house machines.
Other than that, you won't succeed in a open environment such as the Internet.
From your comments, if the user downloading the file is the issue, then there's no way to get around it, as they have to download the file in order to be able to run it.
There's any number of ways to get around whatever you could manage in browser, from proxies like Fiddler intercepting the data, or lower level things like packet sniffing. Or even simply going into the browser's temp/cache folder and copying the file out once it's running.
You could probably get around most laymen by having a program that they can download that registers a file extension with Windows. Then the file downloaded from this site would have the URL of the actual data obfuscated somehow (crypto/encoding/ROT-13/etc). The app would then go and grab the file. The initial program could even have whatever functionality provided by what you want to download, but it needs the downloaded key.
But this is moving into the area of DRM and security by obscurity. If an attacker wants your file, and it's on the Internet, they will get the file.

Downloading a ftp link though a script that changes the address to http

I wrote a script in tcl to grab links out of the download portion of a huge document checking for http:// and ftp:// as links to download. All of the ftp:// links don't require password/username and instead of handling them in separate cases (passing ftp:// to one download method and http:// to another download method) I would just pass all links to one method and substitute ftp:// with http://.
e.g. if I have ftp://server.com/dir/big_file.zip I would pass that along as http://server.com/dir/big_file.zip and download it as that.
I haven't run into any problems testing this with a small sample (testing takes forever because of file sizes) and before I run this overnight to download everything I want to know if is there any possible dangers that will come up? I only need to download, don't need to upload and I'm sure all the ftp links don't have user/passwd.
Also, I know this is probably bad practice but what exactly is the difference between having ftp:// and http:// for a file link when there's no username/password?
If they are all from the same server, it wouldn't pose any authentication problems (if it worked for some, it should work for all of them). FTP and HTTP operate on different ports, so using one over the other would have you downloading the file over a different port. Sometimes FTP can be faster than HTTP (since it's meant for file transfer), so it might be better to use FTP if you can.
Bear in mind that it's entirely possible for a server to make a file accessible via FTP without doing so for HTTP. I'd go so far as to say it's fairly common for that to be the case. That being said, if the server you're hitting does serve all files up in both protocols, then you should be fine.
In the case where some files may not be available via HTTP, one thing you might try is to have the original (FTP) url used as a fallback if the HTTP one fails.

Is there any way to "peek" at a file while it's uploading through HTTP onto a Windows box?

I need to add a file upload function to an ASP.NET website and would like to be able to read a small portion of the file on the server while it's still uploading. A peek or preview type function so I can determine contents and give some feedback to the user while it is still uploading (we're talking about large files here). Is there any way to do this? I'm thinking worst case of writing a custom control which uploads only a fixed number of bytes of the file once chosen and then under the covers starts another upload of the full file. Not totally sure even this is possible, but I'm looking for a more elegant solution anyway... Thanks!
It sounds like you want to avoid the "white screen of death" during large file uploads. If so, you might want to look into Telerik's RadUpload control , which provides a progress bar during upload.
If you want to roll your own, I'd decompile their trial copy for ideas. I've peeked at their source in this way, and they accomplish the progress bar through a combination of a custom HttpModule and HttpHandler along with their control. The handler routes the file in a streamed fashion while the module provides "percent complete" information--or the other way round; it's been a few years since I looked at it.
Edit:
Actually, I'm trying to do server-side processing as the file is still being uploaded. I want to import user data via HTTP, but want to present the user with preview/options of how we'll process their data while the file is still uploading (column definitions, etc.). No matter what, we'll take the file as is, so the upload doesn't need to be interrupted. Given that I actually want interaction during the upload based on reading a relatively small portion of the file as it is being uploaded, would you still recommend the same approach?
Well... it'd be very difficult to do, and it might not work cross-browser, but it could be done with this approach.
Since it's entirely possible to work with the incoming file as a stream as I mentioned, you could have your intial processing update some state as part of that stream processing. If you don't process as a stream, you have to wait for the full file upload before you can do anything with it.
The problem is this: during the file upload, you cannot have any more HTML-based interaction. The post must continue unabated or the upload will fail. The control I linked only works at all because most browsers allow javascript to continue to execute and update page DOM during the post.
So in order to make this work, you have to update some standardized state server-side during your file processing in the HttpModule, which is transmitted back to the client via XmlHttpRequest calls handled by the HttpHandler. You have to use pure javascript/DOM to update the UI for the user.
So, as I said, it's complex and likely to be buggy cross-browser, but it could theoretically be done.
There are alernatives that might be more stable, but might not necessarily be feasible: you could build an ActiveX control or a Click-Once .NET application that pre-processes the file before upload, and maybe even asynchronously transfers the file while the user continues browsing. Some users may not like that option, and I don't know the particulars of your deployment scenario, but it's an option.
There is an HTTP HEAD method but not PEEK.
HEAD will give you information and headers about the file.
Of course you can make a special request handler that does anything you want. You don't have to work with static resources, you can dynamically create any response you want.

Getting data into flex charts from csv

I am developing a flex charting web application which gets data from csv files. This application is supposed to be installed on the website of a client. The client uses a web server management system where the URLs generated are pretty long and contain non-alphanumeric characters. An example is given below:
http://www.example.com/EXTERNAL/ORGANIZATION/0,,contentMDK:20135608~pagePK:64060242~piPK:64060289~theSitePK:299948,00.html
The problem is that on my test server, the application is running just fine. But when deployed on the client's site, the application and the charts load, but the CSV data fails to load. The error given is:
Input output error: IO_ERROR
I have tried both relative referencing (relative with respect to the swf file) and absolute reference to the URL of the csv file. But both approaches have failed.
Any ideas?
I would ideally like to stay away from absolute URLs since that would break down if the charts need to move to another location.
Thanks
Vinayak
Umm, I don't know what to say really. Not knowing much about the server I'll have to resort to a list of things I can think of. Some of these are admittedly just a stab in the dark. In general it appears that this is a server side issue and as a front end developer you can't be expected to solve this. I know that getting the application to work is the priority here, but if you don't have access to the server there not much you can do to this issue.
First let's eliminate the completely obvious. Is the file ending definitely supposed to be .html and not .csv?
My original thought was that the CMS is somehow blocking Flash from loading the content, but would allow a browser to access it. Since it won't allow that either there are three options that come to mind:
1) The server or the browser does something to the URL when you make the request. Try installing the LiveHTTPHeaders (link) add on for Firefox, that'll allow you to look at the raw HTTP requests and responses. There might be some server side redirects that affect the request. The HTTP Headers should help you with that too.
2) The .csv files are kept in a folder that the web server doesn't have read access to.
3) maybe you need to use HTTPS instead of HTTP. This would be a bit strange since you are getting the URL from the server in the first place. The clients server admin should be able to sort this out for you.
4) I'm not sure what would happen if the script that handles your request is Python. In Python the colons are directory separators, so that might throw the whole thing off.
5) The clients management system does something strange to the URL before it's handed to you. Although I'm not sure how you would test this.
That's it I think. I'm out of ideas for now. For the testing I would forget the flex application and just try the requests from the browser address bar first. Since the application is working on your test server the issue shouldn't be your code. When you get the requests to work on the browser, if they still don't work from Flex then it's your code.
I don't know how much it helps, but there is an as3 CSVLib available.
About the IOError, can you please paste the text ?
If you listen for the IOErrorEvent and trace event.text in the handler,
you should something similar to this:
Error #2035: URL Not Found. URL: yourFile.csv
HTH,
George

Resources