yi-hack-v5 icon indicating copy to clipboard operation
yi-hack-v5 copied to clipboard

FTP "Create directory tree" issues

Open fraserp opened this issue 1 year ago • 7 comments

I'm not sure if this is a problem with the FTP server (FileZilla Server, Windows) or the way the FTP Upload works on the camera but when I enable "Create directory tree" on Yi-Hack-V5 (0.4.1e) the video files do not upload. When I turn it off, they do, but of course all to the FTP root directory with unhelpful filenames ({xx}M{yy}S.mp4) to all be in the same folder.

The FileZilla FTP log shows the following:

<Date/Time> Info [Type] Message
<09/02/2024 13:16:28> FTP Session 47 192.168.50.205 [Response] 220-FileZilla Server 1.8.1
<09/02/2024 13:16:28> FTP Session 47 192.168.50.205 [Response] 220 Please visit https://filezilla-project.org/
<09/02/2024 13:16:28> FTP Session 47 192.168.50.205 [Command] USER yi-cam
<09/02/2024 13:16:28> FTP Session 47 192.168.50.205 [Response] 331 Please, specify the password.
<09/02/2024 13:16:28> FTP Session 47 192.168.50.205 [Command] PASS ****
<09/02/2024 13:16:28> FTP Session 47 192.168.50.205 [Response] 230 Login successful.
<09/02/2024 13:16:28> FTP Session 47 192.168.50.205 yi-cam [Command] TYPE I
<09/02/2024 13:16:28> FTP Session 47 192.168.50.205 yi-cam [Response] 200 Type set to I
<09/02/2024 13:16:28> FTP Session 47 192.168.50.205 yi-cam [Command] EPSV
<09/02/2024 13:16:28> FTP Session 47 192.168.50.205 yi-cam [Response] 229 Entering Extended Passive Mode (|||49989|)
<09/02/2024 13:16:28> FTP Session 47 192.168.50.205 yi-cam [Command] STOR videos/2024Y02M02D07H/45M00S.mp4
<09/02/2024 13:16:28> FTP Session 47 192.168.50.205 yi-cam [Response] 550 This function is not supported on this system.
<09/02/2024 13:16:28> FTP Server [Status] Session 47 ended gracefully.

I've also ensure the permissions on the folder ('videos'), which I created by FTPing in via another machine, are set to 777.

Anyone managed to solve this? Am I right in thinking it could be FileZilla Server's interpretation of the STOR commend or possibly some other perm pensions issue?

fraserp avatar Feb 09 '24 14:02 fraserp

I've tried setting up a different FT server with Xlight FTP. Similar errors:

02/11/2024 11:11:39 (not login 192.168.50.205<--192.168.50.11:21) "331 Password required for yi-cam"
02/11/2024 11:11:39 (not login 192.168.50.205-->192.168.50.11:21) "PASS *****"
02/11/2024 11:11:39 (yi-cam 192.168.50.205<--192.168.50.11:21) "230 Login OK"
02/11/2024 11:11:39 (yi-cam 192.168.50.205-->192.168.50.11:21) "TYPE I"
02/11/2024 11:11:39 (yi-cam 192.168.50.205<--192.168.50.11:21) "200 Type set to I."
02/11/2024 11:11:39 (yi-cam 192.168.50.205-->192.168.50.11:21) "EPSV"
02/11/2024 11:11:39 (yi-cam 192.168.50.205<--192.168.50.11:21) "229 Entering Passive Mode (|||54293|)"
02/11/2024 11:11:39 (yi-cam 192.168.50.205-->192.168.50.11:21) "STOR 2024Y02M03D09H/13M30S.mp4"
02/11/2024 11:11:39 (yi-cam 192.168.50.205<--192.168.50.11:21) "451 Cannot create file "13M30S.mp4"."

I have also confirmed that I can write files and directories using FileZilla Client on both the FileZilla Server and the Xlight FTP Server. So I don't think its a permissions issue with the FTP server or Windows.

Again turning off 'Create Directory tree' works just fine:

02/11/2024 11:18:27 (not login 192.168.50.205<--192.168.50.11:21) "220 Xlight FTP Server 3.9 ready..."
02/11/2024 11:18:28 (not login 192.168.50.205-->192.168.50.11:21) "USER yi-cam"
02/11/2024 11:18:28 (not login 192.168.50.205<--192.168.50.11:21) "331 Password required for yi-cam"
02/11/2024 11:18:28 (not login 192.168.50.205-->192.168.50.11:21) "PASS *****"
02/11/2024 11:18:28 (yi-cam 192.168.50.205<--192.168.50.11:21) "230 Login OK"
02/11/2024 11:18:28 (yi-cam 192.168.50.205-->192.168.50.11:21) "TYPE I"
02/11/2024 11:18:28 (yi-cam 192.168.50.205<--192.168.50.11:21) "200 Type set to I."
02/11/2024 11:18:28 (yi-cam 192.168.50.205-->192.168.50.11:21) "EPSV"
02/11/2024 11:18:28 (yi-cam 192.168.50.205<--192.168.50.11:21) "229 Entering Passive Mode (|||54421|)"
02/11/2024 11:18:28 (yi-cam 192.168.50.205-->192.168.50.11:21) "STOR 55M12S.mp4"
02/11/2024 11:18:28 (yi-cam 192.168.50.205<--192.168.50.11:21) "150 Opening BINARY mode data connection for 55M12S.mp4."
02/11/2024 11:18:35 (yi-cam 192.168.50.205<--192.168.50.11:21) "226 Transfer complete (0.000 KB/s)."
02/11/2024 11:18:35 (yi-cam 192.168.50.205-->192.168.50.11:21) "QUIT"
02/11/2024 11:18:35 (yi-cam 192.168.50.205<--192.168.50.11:21) "221 Good-Bye"

Happy to try any suggestions.

fraserp avatar Feb 11 '24 11:02 fraserp

Ill try with my QNAP FTP server - I am sure I have done it already when tested but could be wrong.

alienatedsec avatar Feb 11 '24 23:02 alienatedsec

My guess is that some FTP clients don't allow STOR to create both the file and the folder, so in this instance its failing to create the file because the folder is missing. No idea what the FTP protocal spec says for this. So perhaps a MKDIR to create the folder first would solve this? (assuming also this would fail or be skipped itself if a folder of that name exists?)

fraserp avatar Feb 12 '24 09:02 fraserp

This issue has been stale for 30 days - it will be closed within the next 7 days if not updated

github-actions[bot] avatar Mar 14 '24 06:03 github-actions[bot]

Has anything been changed that I need to test? Or is the auto-close just set to be a bit aggressive about "won't fix" issues?

fraserp avatar Mar 22 '24 09:03 fraserp

Apologies @fraserp

The bot option is to get rid of stale issues, so there is some clarify of which issues are still persistent.

While I haven't used the FTP for a while I had to set it up myself. I use QNAP QuFTP service app and this was the outcome with folders created as expected. The modified date is recent as created recently :)

image

The config page looks like this.

image

alienatedsec avatar Mar 22 '24 13:03 alienatedsec

My FTP settings are the same... so as I suggested in a previous comment I suspect some FTP clients don't create a folder if not present when the STOR command is sent and instead return an error .. or at leas that's my guess

fraserp avatar Mar 24 '24 08:03 fraserp

This issue has been stale for 30 days - it will be closed within the next 7 days if not updated

github-actions[bot] avatar Apr 24 '24 06:04 github-actions[bot]

Gosh, this bot really doesn't like this issue!

fraserp avatar May 03 '24 08:05 fraserp

I would need your setup with me to recreate and possibly fix it. That is neither efficient nor feasible. I can implement or merge pull requests if you have a fix or point at the code or solution that works.

Otherwise, the bot closed it as it was stale for another 30 days - people always forget about issues they raised even if those are being resolved.

alienatedsec avatar May 03 '24 08:05 alienatedsec

Hello everyone!

My camera currently uses the yi-hack-Allwinner-v2 firmware, but I recently encountered the same problem.

I have a Filezilla server on Windows to which a Dahua IPCam is connected and uploading. This camera is capable of managing directory trees corresponding to days and hours.

Trying to configure yi-hack to automatically upload saved video files to a tree, I keep getting "550 Couldn't open the file or directory" errors. However, if I create the path manually, the camera is capable of uploading a video file, so I assume it has sufficient permissions to do so.

From what I've been able to find out, and following @fraserp 's lead, it seems that some FTP servers don't support the use of STOR in a deep path, and handle it if it doesn't exist; this is the case with FileZilla, from what I've seen. However, others, like vsftpd, are capable of handling this scenario and creating the path themselves.

Checking my FTP server logs, I see that my Dahua camera does the following:

230 Login successful. CWD / 250 CWD command successful PWD 257 "/" is current directory. CWD /ENTRADA 250 CWD command successful TYPE I 200 Type set to I PWD 257 "/" is current directory. CWD / 250 CWD command successful CWD / 250 CWD command successful PWD 257 "/" is current directory. size /ENTRADA/DVRWorkDirectory 213 4016 CWD ENTRADA/2025-05-22/001/dav/21 250 CWD command successful CWD / 250 CWD command successful CWD / 250 CWD command successful PASV 227 Entering Passive Mode () CWD /ENTRADA/2025-05-22/001/dav/21 250 CWD command successful PASV 227 Entering Passive Mode () stor /ENTRADA/DVRWorkDirectory 150 Starting data transfer. stor /ENTRADA/2025-05-22/001/dav/21/21.00.00-21.00.00[R][0@0][0].idx_ 150 Starting data transfer. 226 Operation successful PASV 227 Entering Passive Mode () QUIT 200 Goodbye.

It's true that the Dahua camera records in real time, constantly to the server, but the files rotate every hour, so a new directory is needed every hour or for every motion detected. I understand that they check directly from the Dahua software if the path exists and handle the possibility that it doesn't exist to create it.

Could something similar be implemented in the yi-hack script?

I hope I'm not too mistaken...

Thank you very much and best regards!

agr-dev avatar May 22 '25 20:05 agr-dev