Delete uploaded image if user goes from the page - c#

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.

Related

Uploading 100s of images from Android Tablet using C# web application

I'm sure I'll have plenty of questions concerning this new project.
I'd like to create a web application that will give a user the ability to select say 100+ photos from an Android tablet photo gallery. I want them to be able to start the upload and if they leave the application and come back be able to start where they left off. For instance, select images, click submit, upload 10 out of 100 images, log off, log back in, and start uploading the rest of the images.
Is there a way to do this?
The things I'm not sure about is the location of the images on the Android tablet, whether the images saved on the Android is always in the same location, whether I can access the images without some sort of post (the returning to the upload page after leaving).
Do you have any experience with this or any suggestions?

Chatting and file sharing using C# in Asp.Net Webforms

NET Web-forms based application in c#. I need to add a module in the application which allows chatting between logged in users and users can share files during chatting, like Skype. Meanwhile I have to keep a PERMANENT RECORD of each and every word of conversation and files transferred during the session, on my server. I have a bit idea about the implementation of module to achieve the desired result, but I am sure that is not a good practice. Here is my idea:
Chatting:
While users are chatting, create a data-table which will contain the sender id, receiver id, and message contents. When ever user presses send button or hit Enter, a new row would be inserted in the data-table with both IDs and message contents and then the data-table will be bound to a div etc. to show updated messages to both users. At the end, on an event (like window close etc) data-table will be converted to the XML and the XML file will be stored permanently either on hard disk or in database.
File-transfer:
During chatting whenever user press enter/send button we will check the message contents, if the message being sent is a file (with some extension) then upload the file on server and provide a download link to the receiver.
I hope you got my point.
Problem:
1) I want to share files asynchronously i.e. transfer to the receiver and save on the server at the same time. Is it possible?
2) How to tell one user that the other user is typing?
Is there any better way to implement this module? What sort of knowledge should I have to properly comprehend and implement the module?
Thanks for any guidance.
For web-based real-time chat the current open source standard bearer seems to be SignalR.
There are quite a few discussions here on SO about that product and those should help move you in the right direction.
As far as storage is concerned, that will depend upon the infrastructure you have available and the costs you are willing to incur to build the system.
You might look into using RabbitMQ for message delivery and if you set that up appropriately, you can attach queue listeners that will also perform logging of chats as needed. (There are well documented .NET/C# clients already available for RabbitMQ.) You may also want to check out the Wikipedia page for RabbitMQ.
File transfer would probably be best done through uploading of the file to the web-server and temporary storage there with a link to the file to be downloaded by the other chat client. That causes the server to increase its bandwidth requirements though.
You might also look into running your own XMPP server and using a web interface through SignalR to interface into the XMPP server. It might leverage the most functionality for easing time to market.
Have you looked into SignalR?

WebBrowser control do not download images

I am automating the process of downloading my bank statement. The way I do this is by using a win forms WebBrowser control. I navigate to https://www.bankofamerica.com/ then I find the username and password textboxes in the dom fill them in with c# send click event to the submit button etc etc. Eventually I get to the statement I want to download when ready I just parse the page source.
The process works but it is very slow. In summary I will like to improve the performance of this process These are the things I am considering:
Use fiddler to see the requests and responses hoping I could automate the same process. (The problem with this approach is that the connection is encrypted also I have to set cookies and I belive it will be to complicated to do it this way).
Prevent WebBrowser Control from downloading images and css. That way the page.Ready event will fire earlier and the process could be faster.
I will rader go with option number 2 because I know very little about fiddler and just know the basics of http. How can I speed up this process?
It's trivial to capture encrypted traffic with Fiddler; simply enable the Decrypt HTTPS connections option.
It's also easy to disable download of images from the Web Browser control using the "Ambient DLControl" flags. See http://www.tech-archive.net/Archive/InetSDK/microsoft.public.inetsdk.programming.webbrowser_ctl/2009-01/msg00035.html for an example.

Design Advice on Image Processing Architecture

I'm working on a stock-standard, ASP.NET MVC 3 web application (hosted on IIS 7). The site allows users to upload photos, among other things.
The upload process is as follows:
User makes use of widget (currently plupload) to select files from their PC.
AJAX call happens to my server, with image in HTTP POST (Request.Files)
Server resizes photo N amount of times
Each resized photo is uploaded to Amazon S3
At the moment, the above is implemented with a "fire and forget" technique using .NET 4.0's TPL.
I would like to make the above more flexible and robust. For example, if the image processing fails (it's using GDI, so it's likely), or S3 is down (which happens), i or the user won't know about it.
I'm thinking about hosting a WCF service as a Windows Service, which polls a folder for images.
My main website would simply FTP the image to the "watched" folder, then the service would take care of the image processing and the uploading.
The user doesn't need to be notified "immediately" that the photo is done. In other words, right now we show a "your image is being processed and will be available shortly" message.
To sum up, the service needs to:
Resize images
Upload images to S3
Read/write to database
Ability to "retry" failed images
Any advice? Is FileSystemWatcher a good option?
In my current project we implemented a similar middleware service responsible for data processing using FileSystemWatcher with relative success. Some things to remember about:
Be sure to implement some sort of queueing for core processing. Starting 100 image conversion processes at the same time is not a good idea. Consider using a ThreadPool.
FileSystemWatcher will give notifications as soon as the file gets created, at which point it may still be write-only locked - you will have to perform periodic checks to determine the right moment to start processing. Probably using a main loop and a queue.
Keep track of finely grained status changes (like file_created, file_processing, file_processed, file_uploading etc). You might really need them for debugging.
Hope this helps and good luck.

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

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://..."/>

Categories

Resources