easy way to show images in asp.net from ftp server? - c#

is there any easy way to show images in asp.net page from a ftp server?

If your password is secure then follow below steps :-
You really should create an FTP account that only has access to the folder with the images on your FTP server. Do that as soon as possible.
For a better overall solution, either synchronize the images to your webserver, or write an HTTP handler that will fetch the image server-side and streams the bytes to the client as if the image was on your server. Have a look at System.Net.FtpWebRequest for the second solution.
If you have write access to disk on the web server, you could implement both parts of the solution. So if an image is fetched the first time, write it to disk before sending it to the client. The next time it's requested, simply redirect the request to the image on disk (or dynamically change the URL of the tag for that product). This way, you build a cache of the images on your web server as time passes. Of course, you need to be able to invalidate the cache in case an image is updated.

<img src="ftp://..."/>

Related

Load Images from subDomain/Other Domain in C#

I have a website(www.mydomain.com) which has admin panel(admin.mydomain.com). All images I uploaded through admin panel are stored in sub-domain(admin.subdomain/Content/Images/image1.jpg).
Now I need to load these images in my website, for that I have option to assign image's url as src = "admin.subdomain/Content/Images/image1.jpg".
My question is, will it cause performance problem to load images through url rather than giving Image path, if not then I'll go with it, if yes then how to overcome this.
There are two things that will affect performance:
Sending out the a full domain to the browser will be sending more bytes. It's the difference between /images/whatever.jpg and http://admin.somedomain.com/images/whatever.jpg. However, this is such a tiny difference, you would need to be running at massive scale to notice any difference on your bandwidth, and certainly a client wouldn't see any difference.
Browsers will only open a limited number of connections to the same domain. This means if you host Javascript files, images, CSS etc. on the same server, the browser will queue up those requests. So hosting your images on another domain allows the browser to download them at the same time, making the whole process faster. That's why many sites will use a CDN to host their resources. For example, take a look at this site. Even the logo is hosted on cdn.sstatic.net

Uploading a large file (up to 100gb) through ASP.NET application

I need to somehow implement an ability to upload files through an ASP.NET application which is working within our corporate network. The problem is those files are getting increasingly big. At the moment we're using a very generic asynchronous upload but the problem is that files are getting increasingly big and the max limit of 3.9gb per file set through maxAllowedContentLength since the max value of uint won't allow anything more. Soon files which users are suppose to upload will exceed this value and might reach up to 100gb in size.
I tried looking online for some solution to this problem but in most articles by large files people mean 1gb at best.
So is there any way to upload really large files (up to 100g) through ASP.NET MVC\WebAPI application or I need to look for alternative solutions?
Yes there is, you need to split the file in smaller parts see the example here: http://forums.asp.net/t/1742612.aspx?How+to+upload+a+big+file+in+Mvc+
You could consider sending it in chunks. This would skip over the large file requirement (as each request would only be the size of the chunk you send), but is slightly more complicated on the client and server side.
I've done something similar for streaming uploaded files over a websocket, but this could easily be done with multiple ajax requests. In either case you'll want to use the JavaScript File API to read a segment of the file on the client's computer, encode that segment to something you can send (probably Base64), and send that particular segment to the web server. You could also send additional data such as file position to ensure the server is writing the file properly. The server can choose how to respond (can be as simple as a "true" to acknowledge receipt), after which the client javascript would read and send the next chunk of the file.
I have a demo of this using WebSockets on a github repo here (ASP.NET MVC server-side code here) but with a few tweaks you could easily make this into sequential AJAX requests.

Delete uploaded image if user goes from the page

I develop web application functionality sending message with attached image to another user. User can see preview of the image and make some crop before sending.
So at first I upload the image to the server and than show this image for user for preview. But what if user just close browser or go to another page, then there will be unused image file on the server. How to handle it? Or maybe there is better approach that don't need to upload image to the server at all?
This is something that can be done using JavaScript's FileReader. You can edit the image on the client side without having to upload the image to the server. Then you can perform the upload only when the user opts to send the message. This article has an example of such functionality: http://www.aspsnippets.com/Articles/Crop-and-Upload-Image-with-Thumbnail-using-jQuery-and-HTML5-in-ASPNet.aspx
To provide a good user experience a website should give him a welcome back. So in your case you can use the AnonymousIdentification to keep track of your returned users even if the browser is crashed or the tab is closed.
You can keep the information related to that specific anonymous user and keep track of them with their activities including the Image uploading (in your case). Then if the doesn't come back for a specific time of period you can delete that uploaded image.
Or maybe there is better approach that don't need to upload image to the server at all?
Yes it can be achieved via HTML5 features for file handling and canvas feature.
See these links for details:
Html5_ImageUploader
Drag&Drop with Crop via Ajax
I have built this before with a timestamp, after the crop you remove the timestamp in the table.
Have a service that runs say every 15 minute and looks for unconfirmed images and then delete from the server. This obviously still gives the data transfer but works quite well. I don't know how to handle EACH client close (even browser crashes....)
this plugins http://fengyuanchen.github.io/cropper/
http://deepliquid.com/content/Jcrop.html will crop image without upload to server.

Throttle or kill large file uploads in asp.net (httphandler, webapi, or mvc controller)

I need low level control over http file uploads so I can kill an upload early.
Background:
We have a application (an httphandler) that serves downloads of media. It is able to throttle the downloads and also it's able to embed some encrypted meta-data in the file as it is being served to the client.
Here's what I'm trying to do:
I'm trying to figure out how to do the reverse of what I wrote above. I want to give our users the ability to upload one of these files so that our app can extract the encrypted data, decrypt it, and present it to the user. The problem is that these files can be big (200+ MB). The metadata though, is at the beginning of the file and we're able to read it even if the file is just a fragment.
So, does anyone know how I can gain low level control over the file upload so I can get the first N bytes of the file and then kill the upload? I'm hoping this is similar to the code I wrote for throttling downloads. I'm open to doing this via an httphandler, the webapi, or any other way that would be easy.

send image via web service

I want to write one program by visual studio 2008 (C# and ASP) that has web application and windows application.
I want to get clients images in web app(upload) and store them in DB (mysql) then send these images to windows app via web service (so i new web service, not web site). But i have 2 problems:
I have 2 ways to store images in mysql, first i should have BLOB field in DB -that it takes more space-, second i should save just name of each image in DB(so have image in one folder) -in this way i don't know how get image from clients and store them in that folder-. which one? Or what other?
How (code) can i transfer image via web service(Byte[] or? ).
One of the options to transfer the image using WCF is to convert image to byte array and pass it to client. Then convert from byte[] to image on client side.
Question 1:
The images or links in DB debase is old and still unresolved. There was a microsoft white paper that came out that recommended (for SQL Server 2008, so your mileage may vary) that for images/binaries under 150k DB storage is a good compromise. If most images are over, go with links, if under, store in DB.
Question 2:
The webservice will have an http context object, so you could simply use the Response.BinaryWrite method, that takes a byte[]. You will still need to write the correct headers (for mime type etc).
For a file on disk, the simplest thing to do is use the Response.WriteFile method that takes a file path argument.
In either case, you will need to intercept this on the client and convert back to an image.

Categories

Resources