Hi,
I would like to sync files and folders between iPad, iPhone and my NAS. I have a Synology Diskstation which supports WebDAV (like NextCloud and OwnCloud) and SMB. The objective is to have files available offline and when I push a file from iPad to the server having it available on iPhone, too. So, I thought a scriptable widget which is triggered time by time is the best way to sync the folders. However, I struggle with the filemanagement.
Attempt 1 - File Bookmarks
At first, I used the scriptable „File Bookmarks“. The bookmarks should manage the folder on iOS and the folder on the NAS. The file system of the NAS can be includes into the iOS File manager via
smb://192.168.178.30
(Only available form WiFi at home.) I included the bookmark into scriptable with the following command:
const fm = FileManager.local();
const serverPath = fm.bookmarkedPath("serverVerzeichnis");
Where „serverVerzeichnis“ is the File Bookmark within scriptable.
The disadvantage of this method is, that the files are only available at home. But this can be overcome with a VPN connection to the rooter.
However the bookmarks are not stable. Every day I have to delete and create new File Bookmark as iOS (or scriptable) can‘t find it. I have to admit, that my NAS is down at night (energy saving) and restarts every morning. Also WiFi is of at night, so the login has to start every day new. I was expecting that the File Bookmarks will work for ever but for me they don‘t. So here are my questions:
- What are the basic principles of the File Bookmarks? I don‘t yet fully understand, what they can do and what they can’t.
- Is there a possibility to push scriptable to reininitiate the File Bookmarks?
Attempt 2 - direct Link
I also tried to use the direct link:
/var/mobile/Library/LiveFiles/com.apple.filesystems.smbclientd/Wzt...
with the following code
Let serverPath = "/var/mobile/Library/LiveFiles/com.apple.filesystems.smbclientd/Wzt...“
The good news are the name after smblientd/ seems to be stable within iOS. But also the File app is loosing the connection after a certain time.
- How can I force iOS/iPadOS to reintegrate the SMB-Filesystem into the local file system?
Attempt 3 - WebDAV
My third idea was to directly access the NAS via WebDAV. Here, I struggled with the syntax of WebDAV. I am able to upload and download a file but didn‘t understand how to retrieve additional informations like the content of a folder or the date of a file.
The scriptable commands look like this
var url = "https://server.com:port/folder/file“;
var req = new Request(url);
req.headers = {"Authorization":Login};
var content;
content = await req.load();
fm.write(filePath, content)
The standard port for a WebDAV-Server on a synology diskstation is 5006. The Login is a created best with shortcuts using user:password and than encode with base 64.
The advantage of the access via WebDAV is, that the files can be accessed from anywhere.
By the way: It is also possible to access WebDAV via shortcuts. The following commands are required:
Get contents of URL
Method:GET (for download or PUT for upload)
Headers:
Authorization: Basic LOGIN
Request Body: File
File: The_File
(Space between Basic and LOGIN. LOGIN again is encode with base 64 from user:password.)
I was trying to understand the WebDAV-Specifications at
https://greenbytes.de/tech/webdav/rfc4918.html#rfc.section.9.1
But I didn‘t figure out how to send PROPFIND to the WebDAV server.
Here again my questions regarding WebDAV:
- How can I receive additional informations about a file (I need date) or a folder (I need the content)?
- What happens to the date of a file when I store it locally?
- Is there a chance to give the local file the same date as the server file?
I am already able to upload and download files to and from the server via shortcuts. It would be create if I can download the files automatically with the widget.
As I am not able to receive additional informations about the files and folders I have a workaround. Currently I write all the files I like to sync into an additional file which I can acces from any device. In the file the files which should be available for any device are listed so I can download them. However, I haven‘t found a way to manage the date and time information about the files, yet.
I am very thankful for any hints to increase my concepts.