Store files temporarily on server until a task is completed
I cant use sessions.
So heres the scenario: I want the user to upload an image, but that image needs to be a particular si开发者_开发百科ze. So I allow them to upload any size image, store that temporarily on the server (resize it so it fits on the webpage), display it back to the user, let the user crop it. I then send the crop details back to the server, crop the image and save it and use it as the users profile picture.
I tried to do all this before uploading, but apparently, its a security risk and not allowed.
So how do I temporarily store this file? What if the user does not come back before cropping, I dont want a large image like that sitting on my server. How would I go about removing the file in a stateless application like this?
Files are stored on a CDN.
There are lots of ways to solve this, but perhaps an easy way is that every time a file is uploaded, call a little routine that checks for, and deletes, any 'large' files that are over xxx minutes old.
Alternatively, schedule a job to do the same every xxx minutes in the task scheduler.
You can use TempData, which is similar to Session, but dies after being read.
精彩评论