Upload iPad Video to NAS server
Part 1 of a journey to automoate video archiving and publishment
This is part of a journey of automating my video publishment from iPad to Youtube, WeChat and etc. The whole solution background is available at https://medium.com/tech-life-fun/video-publishment-automation-935d5120dc9b.
Environment Involved
1, an iPad with shortcuts availabe.
Shortcuts need to be able to delete files without confirmation.
2, a NAS server (I’m using a Synology NAS). Certainly it can be any Linux server.
Steps (how-tos)
1. In the NAS server, set up a HTTP file server that supports upload using POST.
The simple upload server I use is:
I have deployed its docker image into my NAS with below settings:
a) Execution Command
Please note that I set upload_limit to be 500MB+ since video files are usually big.
/usr/local/bin/app -token <my-token> -upload_limit 52428800000 /video
b) Map an external port (here is 25479) to container port 25478.
c) Mount a local folder to /video which is used in the execution command as an argument.
d) Now if I copy a file named test.txt to the local folder, I should be able to use http://<NAS-IP>:25479/files/test.txt?toke=<my-token>
2. Write a iOS shortcut to allow video(s) selection; the shortcut can then upload the video(s) to the file server and delete those videos.
Since I’m a beginner of iOS shortcut programming, I actually learn from an existing shortcut mentioned at https://www.reddit.com/r/shortcuts/comments/9klkcs/a_shortcut_to_upload_camera_roll_media_to_your/.
Anyway, below is my shortcut which can be opened in an iOS device (iPad for example):
https://www.icloud.com/shortcuts/b83a133b316845bb91ea630fe8df96f1
For a quick glimpse, here is a screenshot. “[var]” needs to be replaced with actual value. For example, if in above step “token” is set to be “my-token” then “[token]” needs to be replaced with “my-token”. Please be aware there are 2 “Get contents” actions and both actions should go through the replacement process.
Appendix — Detours
1, While above steps may look (hopefully) straightforward, I actaully do not figure them out in the beginning.
When designing/implementing a solution, there are always some detours in the journey. Below are some thoughts that are not working well but that do take me several hours to learn/realize.
At first I thought about using SFTP so I just go ahead and enable it in Synology DSM like below.
Also, I grant my daughter’s account SFTP access.
It does work when I try to use a SFTP client to upload files. However, Apple Shortcuts do not offer SFTP out of the box so I have to refer to SSH script. SSH script needs to be run inside Synology NAS and that’s where I run into a problem: my daughter’s account doesn’t belong to an admin group and that means it cannot SSH into my NAS!
Only after that I’m aware that I should look for a simple file server (with upload support via POST ideally) and come across https://hub.docker.com/r/mayth/simple-upload-server.
2, I had a hard time (~2 hours) to get iOS shortcuts to upload files to my upload server.
Below link gives me a lot help (the most important part is: use Form instead of File as the request body and “file” as the form field name).