-
Notifications
You must be signed in to change notification settings - Fork 354
[GUIDE] iOS Upload Workflow
On iOS, there are a bunch of good scanning apps (even the built-in document scanner is great for most cases). However, only a few apps support uploading the documents to the paperless server via FTP, SMB, etc. after scanning. At least not in the free versions. I've been looking for a few months now, and haven't seen a free app that would allow me to upload the file after scanning. In the meantime, I have found a good workflow which currently works quite well for ME. And since I haven't seen a tutorial for iOS here yet, I thought I'd share my way here, maybe it will help one person :).
-
OPTIONAL: A scanner app.
- I use SwiftScan and Adobe Scan, but the following way should work with almost ANY scan app from the AppStore.
- the built-in scanner app works just as well
- Shortcuts
- Shortcuts is an app that allows you to create some automations on iOS. For example, turn on a light when the last person leaves the house, QR generation and much more. By now the Shortcuts app is really well developed and you can create many small tools with it. For example, I built a URL shortener using Shortcuts. I can only recommend the app to every iOS user who is interested in automations or small scripts.
- Shortcuts should be preinstalled, but it can also be installed from the AppStore
- SSH access to the paperless server
App used: Adobe Scan
https://www.youtube.com/watch?v=5KjCygxwSuw
The idea is that we create a shortcut which does the following:
- Accept PDFs and files by sharing them to the shortcut
-
IF file was passed
- THEN take file from input
- ELSE open a dialog, where you can select a file
- Extract information like name and file extension
- Replace
\
in filename (to allow spaces in filename) - Login to the paperless server via SSH, execute the following command:
# Save input under the path `{remote_path}`
cat > {remote_path}
# Verify if file exists
ls -la {remote_path}
- Done!
In order for the shortcut to access the Paperless server via SSH, the shortcut must authenticate via a password, or SSH key. The SSH key cannot be secured with a password, as far as I know.
Thus, anyone who has access to your iPhone can log in to the paperless server.
Therefore, you should create an extra user with highly restricted access rights, which will only have access to the consumer folder.
In my case, though, it doesn't really matter because my paperless server is only exposed on my local network, and if anyone has access to it, they have access to the physical hardware. Besides, my iPhone is also (sufficiently) protected.
You can also get my shortcut here (last update: 2021-03-31, 7:41 PM), and then adjust the values to your application purpose.
Open the Shortcuts app -> "My Shortcuts" -> click on the "+" at the top.
Now click on the blue circle with 3 dots in the upper right corner. There you can, if you like, give it a name, change the icon and add the shortcut to the home screen.
Then activate Show in Share Sheet
and select PDFs
and Files
in Share Sheet Types
.
When you are done, click "Done" in the upper right corner.
Next, click on the blue circle with the "+" and select Get Details of Files
. Then click on File Size
and select Name
.
We now save the value in a variable by clicking on the "+" again and selecting "Set Variable".
At Variable Name
we can now assign a name, for example File Name
:
Let's repeat the same for File Extension
.
In Linux, spaces in paths are indicated by \
, so we need to replace spaces with \
. This is also easily possible via the action Replace Text
, which is inserted between Get Name from ...
and Set variable ...
.
In Hello
we write
and in World
we write \
.
To upload the file to Paperless we add the "Run Script Over SSH" action.
Here you have to enter the Host
of Paperless, the SSH Port
, the User
name and an Authentication
-Method (read the security note above). Since I prefer authentication via SSH keys, I select "SSH Key".
Select Shortcut Input
under Input
and enter the following command:
cat > ~/paperless/consumer/(File Name).(File Name)
NOTE: To enter the File Name and File Extension placeholders, just click in the text field. Above the keyboard a field appears, over which variables can be inserted by clicking.
NOTE: The SSH key is generated by the iPhone, which must then be stored in paperless.
To generate, click on the SSH key and select Generate New Key
. I used RSA
with 4096
bits for the generation.
When you are done, click Share Public Key
and add it to your Paperless user. See: linuxhandbook.com
$ mkdir -p ~/.ssh && echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCSx5mBYPqSe0zy6YAs94Wxapj1o9nxaVBxjnYxPWo8HXe8HRg [...] Shortcuts on Daniel’s iPhone" >> ~/.ssh/authorized_keys
The shortcut can now be tested. If something does not work, you can also test my provided shortcut at TL;DR.