wmnnd

wmnnd

Belt - A Flexible File-Storage Library

Hi there,

for my project DBLSQD, I needed a file storage solution that is a bit more flexible than Arc. Because I thought others might find it useful as well, I decided to share it with everyone and release it as free software. You can install version 0.1.1 from hex.pm.

What can it do?

Belt allows you to store files on remote or local systems. Currently, SFTP, S3 and the local filesystem are supported as targets. Belt is especially useful if you want to target multiple storage systems that are configured at runtime (e. g. because they are user-provided).
Belt is built on top of GenStage and also supports asynchronous uploads.

Belt also offers some convenience functions such as retrieving hashes of a file.

How does it work?

Here is a little example on how to use Belt:

#Simple file upload
{:ok, config} = Belt.Provider.SFTP.new(host: "example.com", directory: "/var/files",
                                       user: "…", password: "…")
Belt.store(config, "/path/to/local/file.ext")
#=> {:ok, %Belt.FileInfo{…}}


#Asynchronous file upload
{:ok, config} = Belt.Provider.S3.new(access_key_id: "…", secret_access_key: "…",
                                     bucket: "belt-file-bucket")
{:ok, job} = Belt.store_async(config, "/path/to/local/file.ext")
#Do other things while Belt is uploading in the background
Belt.await(job)
#=> {:ok, %Belt.FileInfo{…}}

You can read more on how to install and configure Belt in the Getting Started guide.

Roadmap

Belt is definitely usable the way it is right now but I have planned several additional features such as an Ecto integration.

Feedback welcome!

Suggestions for useful new features are more than welcome.
Also, if you discover bugs or find the documentation lacking in any way, please file a bug report.

Most Liked

wmnnd

wmnnd

Upload in-memory data with Belt 0.4.0!

Thanks to @jayjun’s fantastic work, a brand-new feature is now available in Belt: Uploading iodata directly to all Providers without the need to go through a file first.
Belt.store_data/3 works just like Belt.store/3, except that it takes iodata instead of a file path as the second argument and the :key option is mandatory.
Of course, it’s also accompanied by Belt.store_data_async/3 :slight_smile:

I’ve also updated the ex_aws dependency to the 2.x branch.
I originally wasn’t sure if this is the right thing to do, since it’s a major version update for this (optional) dependency and just a minor version update for Belt.
But since there is a bug in ExAws 1.x which breaks it on Elixir 16/OTP 21 and @benwilson512 pointed out that ExAws 2.x is “plug and play compatible” with 1.x, I decided this was the way to go :crystal_ball:

As always, Feedback is very welcome.

wmnnd

wmnnd

#New version 0.1.8
Since DBLSQD is finally up and running, there is at least one instance of Belt out in the wild now :smile:

More features will come as DBLSQD and Belt evolve. For now, these are the changes of the most recent release:

Changelog

  • Improvement: When storing files on SFTP, hashes are now calculated locally. Retrieving hashes when none were requested is now a noop.
  • Improvement: Better compatibility with SFTP servers with small maximum package sizes. Thanks to the obscure and undocumented (yet public) functions :ssh_sftp.send_window/2 and :ssh_sftp.recv_window/2, package size is now determined dynamically.
  • Fixed bug causing infinite loops when listing files on some SFTP servers
  • Fixed connecting to SFTP servers with verify_host set to false

###Roadmap

  • Make jobs more flexible
  • Explore the possibility of using ETS directly or ConCache as a backend for jobs

Feedback and suggestions are welcome as always!

wmnnd

wmnnd

Small SFTP update 0.2.0

Version 0.2.0 of Belt brings improved SFTP transfer performance (as much as 10 times faster transfer speed) thanks to asynchronous writing as well as better support for different SFTP servers.

What’s next?

Belt 0.x will continue to receive updates and soon I’ll add a feature to test configurations without the need to upload something or use one of the other commands first.
A rewrite is coming for version 1.x which will bring new Ecto-style configuration and direct uploads - both for S3 and by proxy for SFTP as well.

wmnnd

wmnnd

Tiny update: Fixed typespecs in Belt 0.4.1

As @maennchen pointed out, there were some inconsistencies in the typespecs of Belt.await/2 when used with Belt.delete/3, Belt.delete_scope/3 and Belt.delete_all/2.
Now the typespecs and docs correctly reflect that all deletion functions return :ok instead of {:ok, term} upon success. This doesn’t change the actual behavior of any code using these functions. If your code worked before, it’s still going to work now :slight_smile:

wmnnd

wmnnd

New version 0.5.0

I have just released a new version of Belt, version 0.5.0

Changelog

  • Requires at least Elixir 1.7 now
  • Better support for current Elixir versions with no pesky compile-time warnings

I’d be happy to hear feature suggestions or experiences from people out there using Belt. It’s been working really well in production for me for quite a while which is why there has not been a lot of development activity :slight_smile:

Where Next?

Popular in Libraries Top

Qqwy
Solution is a library to help you with working with ok/error-tuples in case and with-expressions by exposing special matching macros, as ...
New
mhanberg
I just released the first version of Temple: an HTML DSL for Elixir and Phoenix! You can read this blog post or the docs for more info...
New
wojtekmach
Hey everyone! Req is an HTTP client for Elixir that I’ve been working on for quite some time. There is already a lot of HTTP clients out...
New
kevinlang
Hey all, We have made an Ecto3 Adapter for SQLite3, ecto_sqlite3! We have successfully on-boarded the full suite of integration tests (...
New
entone
ExARI An Elixir library for interfacing with Asterisk using the ARI protocol. Be sure to check out the example application https://git...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 35421 110
New
josevalim
EDIT: since Ecto 3.0 final version is out, this post was amended to use the final versions in the instructions below. Hi everyone, We a...
New
michalmuskala
Another small library today. PersistentEts Hex: persistent_ets | Hex GitHub: GitHub - michalmuskala/persistent_ets Ets table backed by...
New
MRdotB
I needed to reuse React components from my Chrome extension in my Phoenix/LiveView backend. I noticed that for Svelte/Vue, there are live...
New
Qqwy
Hello everyone, I wrote a small library today called MapDiff. It returns a map listing the (smallest amount of) changes to get from map...
New

Other popular topics Top

belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
peerreynders
Manning 2016 Halloween weekend sale via Deal of the Day Friday, October 28 - Half off all MEAPs - code WM102816LT Saturday, October 29 ...
326 29600 154
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
polypush135
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New

Sub Categories:

We're in Beta

About us Mission Statement