将文件临时存储在服务器上,直到任务完成
我无法使用会话。
场景如下:我希望用户上传图像,但该图像需要具有特定的尺寸。因此,我允许他们上传任何尺寸的图像,将其临时存储在服务器上(调整其大小以使其适合网页),将其显示回用户,让用户裁剪它。然后,我将裁剪详细信息发送回服务器,裁剪图像并保存并将其用作用户个人资料图片。
我尝试在上传之前完成所有这些操作,但显然,这是一个安全风险并且是不允许的。
那么如何临时保存这个文件呢?如果用户在裁剪之前没有回来怎么办,我不想在我的服务器上放置这样的大图像。我将如何在这样的无状态应用程序中删除文件?
文件存储在 CDN 上。
I cant use sessions.
So heres the scenario: I want the user to upload an image, but that image needs to be a particular size. 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
有很多方法可以解决这个问题,但也许一个简单的方法是每次上传文件时,调用一个小例程来检查并删除任何超过 xxx 分钟的“大”文件。
或者,在任务计划程序中安排作业每 xxx 分钟执行一次相同的操作。
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.
您可以使用 TempData< /a>,与Session类似,但读完后就消亡了。
You can use TempData, which is similar to Session, but dies after being read.