Need help from someone who understands servers, and downloading files in c# - c#

Let me start by describing what I want to do:
I have a Unity app, and I code it in c#.
In the app I want to download a file from a server, so I am using HttpWebRequest.
I sent out a HEAD request first to see if the file on the device needs to be updated or not, and to see the file size on the server. If the file needs to be updated I download it.
The class that I use for the downloads is in this git.
Now my problem is I don't know how to host the files because of the following issues:
I tried hosting it on a site with direct download links like ge.tt, but it does not support the HEAD request.
I tried hosting it on a free web host (000webhost), but the download gets stuck most of the time (for large files).
I tried hosting it on Dropbox but the function webRequest.EndGetResponse never returns.
I think the best solution would be to host the files on my computer, but I dont know how to do that, or how to get a download link that will work outside of my lan.
I would greatly appreciate any ideas you have, and answer questions about the code.
Thank you!

Related

Create custom code to work around missing rename action on Azure Logic App FTP Connector

We are converting a existing C# console app to a Azure solution.
Pretty basic need:
Store files as blobs that need to be FTP'd to a client.
Insert messages into a Service Bus Topic with a JSON format for file name etc.
Have a logic app subscribe to the topic and FTP the file.
The ftp server is our customers and I cannot change its setup.
It starts processing files as soon as they are put on there and meet a certain naming style.
In the past all I do is put temp_ at the front of the file, then create it, then rename it.
Perfect.
We already have this working using standard .Net code, but now I am trying to get it to work using a Azure Logic app as detailed above.
Using a 'Create File' under the FTP connector. If I create it using the proper name it fails as the FTP server grabs the file before Azure is done creating it.
There is no rename functionality in the FTP connector -- can somebody please tell me I am missing something??
Joe
UPDATE 5-24-18
From Microsoft Tech Support:
After looking further into this, this is not going to be doable using
the out-of-the-box FTP connector.
The logic apps workaround would be to do this from custom code. You
could use the FTP connector’s Create File task to create the file on
the FTP server using the temporary name. Then, you could call a custom
Azure Function that would log into the FTP server and rename the file.
This would require you to create a custom function.
See the following link for more details on calling Azure Functions
from logic apps:
https://learn.microsoft.com/en-us/azure/logic-apps/logic-apps-azure-functions
I am going to attempt to do this and if I can get it to work post it as an answer.
If anybody wants to take a swing at helping me that would be great!
The bigger question I guess here is "why"?
Why go through all this? Why not just use a C# function right from the beginning? The answer is partially just to have the experience of using Service Bus / Topics etc...plus if they ever DO update their FTP connector it will be a easy fix then. But I am still open to other answers or options.
BTW - please vote for that change here if you think it would be helpful:
https://feedback.azure.com/forums/287593-logic-apps/suggestions/19499953-add-rename-action-to-sftp-ftp-storage-etc-connect

How can I implement a simple server to receive files sent via WebClient in C#?

There is a program which sends image files in binary by using WebClient.UploadFile(someUri, "STOR", filename). I can't change that program, but I need to build a program to receive the file. I don't want to implement a full FTP server, so what should I be looking at to create the bare minimum logic in C# to receive the file? A bonus would be a solution that uses features present in .NET 3.5 or 4
I don't really know where to start, so any tip is appreciated. Thanks.
It sounds like you'll need to provide not an FTP server, but an HTTP server (aka a web server). From a little quick Googling, it looks like there's a library for embedding a simple web server into a .net application named Nancy that a lot of people seem to have good results with: Embedded C# web server?
Of course, this would be the quick and dirty way. Probably a better long-term approach would be to create a normal ASP.Net website to receive the images, hosted on a normal IIS web server. But if you have no experience in web development, that might be biting off a lot.
Thank you for the suggestions, but through more digging around I found out how to implement what I need. This is a very simple ftp server done in python using sockets. I was able to easily replicate this in C# using sockets again and I have adapted it to be able to authenticate a user of my choosing and write the received files to the disk.

Streaming large ipa files to iOS devices

Hey everyone I am working on a custom app store for iOS. However, I am having a problem when my system tries to stream large ipa files to the device. Sense there is no way to tell the device the total size of the file during the stream the status bar on the iOS device wont budge until the file is finished downloading then it almost completely fills the status bar in an instant and installs the file. This may leave users to think that the download isn't working at all. I am trying to find an alternative way to handle these large ipa files. I am currently thinking that I could allow the device to make a direct request to the file without hitting any .Net runtime code. I would probably be able to handle this through an ISAPI filter, but then I would need a way to authenticate that request to make sure the user has access to that download. Any advice or input would be appreciated.
Thanks.
You might consider pushing the apps into S3 and sending out signed CloudFront URLs to authenticated users:
http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-signed-urls-overview.html
Alternatively, you could just give the .ipa files very obscure names that would be hard to guess.

Windows application to upload files

I need to make a windows application to upload files (jpg) that are on my computer to a web host. I have tried various codes I found on the web but none of them worked.
Does anyone have a working code to do this? Maybe in VB.NET or C#.
I appreciate the help.
Your question is not revealing more details about your requirement, but still I'm providing couple of ideas on how do that based different scenarios.
First point: you need to be clear about your server side for receiving these files. Whether you want to activate ftp on server and provide ftp credentials to client to upload files to a particular folder. If not ftp then you should have your server listen to post requests from the client to upload files.
FTP: Here is the article to upload files from windows application to a FTP server.
Post: Here is the link for post way.

.Net Cloud Based Storage solution

I am now at the point where i cant get any further with out some help.I am trying to host files on the cloud and then access those files via code (C#). So far i have tried Rapidshare and Skydrive and have been unable to get either working at all. Below is a few things that i am trying to do or rather must be able to do with the cloud storage.
What i need is a place to host files on the internet (obvious).
The files can range in size from 10 megs to 100megs.
I Must be able to download the files via code as well as upload via code.
I don't really mind having to pay as long as the price is not ridiculous.Any help at all will be much appreciated.
Thanks
Stalkerh
Why don't you look at Amazon S3 they do what you want, are cheap and have a C# API wrapping their web service (But ThreeSharp is better).

Categories

Resources