Securely Send Large Files for Free Using Ruby with Firefox Send
We work with many Fintech startups and they are always looking for solutions to reduce out of pocket cost at the same time don’t want to compromise quality and security.
One of our Fintech clients is looking for sharing some confidential documents between users seamlessly using disposable links and track them within app built using Ruby on Rails. We evaluated a couple of free services and finally chosen Firefox Send.
Send is a free encrypted file transfer service that allows users to safely and simply share files from any browser. It uses end-to-end encryption to keep your data secure from the moment you share to the moment your file is opened
— Mozilla
Now there are two ways you can share files using Share:
- Using Browser
- Using Command Line Utility
There is no API available as I am writing this. The easiest way to use the service from Ruby is to use command line library among the available options.
Read Also: File Upload with Box Using Ruby on Rails
Install Firefox Send Client on Ubuntu (18.04)
snap install ffsen
Checkout instructions to install send on other supported platforms.
Upload a File to Test the Setup
Here is a simple command to upload a file from the current directory after installation
ffsend upload insurance
Above command uploads insurance.pdf from the current directory and returns disposable link.
You can use different options as per your need.
Execute Command Line from Ruby
Ruby SDK supports many options to run shell commands out of the box. Jesus Castello has written a nice post How to Run System Commands From Ruby which is worth looking before you check the following script.
Open3 grants you access to stdin, stdout, stderr and a thread to wait for the child process when running another program.
I personally prefer Open3 which is a reliable option over all available option to execute shell commands. Include the above module in a class where you want to execute shell commands. Here is a snippet for uploading the file.
ActiveTransfer.new('sample.txt').transfer
would simply transfer sample.txt
from the current directory and return URL to the file which you can use it to save in the database. Here is output when you execute it.
You can pass different options by specifying it within array passed execute_shell_command
Other Free File Sharing Services worth Looking
At BoTree Technologies, we build enterprise applications with our RoR team of 25+ engineers.
We also specialize in Python, RPA, AI, Django, JavaScript and ReactJS.