如何上载或不上载文件 [英] How Can I Get File Is Uploaded Or Not

查看:106
本文介绍了如何上载或不上载文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我有一个简单的问题,我有在特定时间间隔内运行的窗口服务。

现在我有一个问题,当用户上传一个大文件并在同一时间窗口服务运行并转换该文件使用ffmpeg到mp4但原始视频没有完全上传。因此转换后的视频不起作用。



所以我想在视频上传完成后才转换文件。我怎么知道视频文件上传成功与否?



用户使用Filezilla或其他ftp客户端上传文件。



感谢高级..

解决方案

您的FTP服务器应该知道哪些文件实际上传了。



一个好的实现服务器也会锁定文件,即使在上传过程中进行读取也是如此。然后你的服务可能会检测到新文件但是无法打开它。



如果没有读锁定,至少应该有一个独占的写锁定。因此,您可以尝试打开文件以进行追加(成功时立即关闭它)。失败表示该文件仍在上传。



最后一种方法是获取打开文件句柄列表并检查文件是否在列表中。但是使用C#会很困难(在CP上有一篇使用C ++的文章:列出已用文件 [ ^ ])。

Hi i have a simple question, i have window service that run in specific interval.
Now i have one issue when user upload a big file and during same time window service run and convert that file to mp4 using ffmpeg but original video is not uploaded completely. therefor converted video does not works.

So i want to convert file only after video upload finished. How can i know that video file is uploaded successfully or not ?

user uploads file using Filezilla or other ftp clients.

Thanks in Advanced..

解决方案

Your FTP server should know which files are actually being uploaded.

A good implemented server would also lock the file even for reading while the upload is in progress. Then your service might detect the new file but will be not be able to open it.

If there is no read lock, there should be at least an exclusive write lock. So you can try to open the file for appending (close it immediately upon success). Failure indicates then that the file is still uploading.

The last resort is getting a list of open file handles and check if the file is in the list. But this can be difficult with C# (there is an article using C++ her at CP: Listing Used Files[^]).


这篇关于如何上载或不上载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆