LostKobrakai

LostKobrakai

Depot - Filesystem Abstraction

Depot is a filesystem abstraction inspired by the great flysystem PHP package.

This allows interacting with many different filesystems (cloud based or not) via a common sensible and in some parts simplified API. Change e.g. cloud providers just by switching out the filesystem setup, leaving any business logic as is. It supports both “module based” systems as well as systems setup purely at runtime (thanks to @michalmuskala presisting on it ages ago) .

defmodule LocalFileSystem do
  use Depot.Filesystem,
    adapter: Depot.Adapter.Local,
    prefix: "/some/path/to/storage"
end

LocalFileSystem.write("test.txt", "Hello World")
{:ok, "Hello World"} = LocalFileSystem.read("test.txt")

# or

filesystem = Depot.Adapter.Local.configure(prefix: "/some/other/path/to/storage")
Depot.write(filesystem, "test.txt", "Hello World")
{:ok, "Hello World"} = Depot.read(filesystem, "test.txt")

The following parts are done.

  • Basic API
  • Stream based API (with the help of @mcrumm)
  • Portable visibility (:public vs. :private only)
  • Adapters can support more complex visibility handling
  • Copy between different filesystems with
    • Copy directly on the filesystem (e.g. S3 bucket_01 → bucket_02) if supported.
      Must be same adapter for both filesystems.
    • Copy using streaming via the current machine.
    • Drop to synchronous read/write when streaming is not supported.

Outstanding additions:

  • Further common metadata: Size, Type, …

GitHub:
https://github.com/elixir-depot/depot

The abstraction for the different underlying filesystems are done using adapters:

  • InMemory (Included)
  • Local (Included)
  • S3 (Currently not up to date with latest depot behaviour)
  • Google (Currently not up to date with latest depot behaviour; by @jayjun)

First Post!

dimitarvp

dimitarvp

Does this help you with your problem with backslashed paths that you shared about some time ago?

Most Liked

LostKobrakai

LostKobrakai

I’ve picked up work on this again and am currently trying to get the API and the S3 adapter finalized. Today I bumped into the reality that minio (what I’m using in dev/test) doesn’t support object level ACLs like AWS S3 does, the docs seem to suggest using bucket policies. I’ve not much experience around those policies, so I’m wondering if anyone here does and would like to help me out or collaborate on the visibility handling part of the adapter. I’d really like for the adapter to support not just AWS.

LostKobrakai

LostKobrakai

It was the reason for me bringing it up. One would think using Path.type to enforce only relative paths would work, but it’s os dependent. I ended up just copying the code and modifying it to fit the needs of the module.

hauleth

hauleth

Out of interest, why use Agent in the InMemory adapter instead of ETS? Recently I have used ETS for such behaviour (I should publish that before you published Depot) with 2 tables:

  • “paths” index in form of {path(), hash()}
  • file contents indexed by hash {hash(), content()}

In that way file copies are “cheap” and I do not need to store them twice (in my case I couldn’t rely on Erlang immutability, as I was reading file content from tarballs, so each binary would be “different” from the viewpoint of VM).

I am also preparing the PR with “balckhole” adapter which I often find useful for testing.

BTW

I have reviewed the code and I think it would be useful to make some callbacks optional, as not all adapters will support them, and that would make it easier to implement them for situations when some features aren’t available.

Last Post!

pehbehbeh

pehbehbeh

We also have a PHP/Laravel background and also missed something like Flysystem. We are currently considering building something like this ourselves and came across this library during our research. Are there any current plans to further develop and maintain the package? Is it still alive?

Where Next?

Popular in Announcing Top

bryanjos
Hi, I just published version 0.23.0 of Elixirscript. https://github.com/bryanjos/elixirscript/blob/master/CHANGELOG.md Most of the chan...
New
jakub-zawislak
Hi everyone, I’m coming from the Symfony (PHP) framework. I like Phoenix, but it has a one thing that was build much better in the Symfo...
New
tmbb
I’ve published the first version of my Makeup library. It’s a syntax highlighter for Elixir in the spirit of Pygments, Currently it highl...
New
tmbb
I’ve been working on two packages (not on hex.pm yet) to build admin interfaces for phoenix apps: bureaucrat - which contains a bunch ...
New
devonestes
Introducing assertions, the library that helps you write really great test assertions! GitHub: GitHub - devonestes/assertions: Helpful a...
New
sasajuric
I’d like to announce a small library called boundaries. This is an experimental project which explores the idea of enforcing boundaries ...
New
zachdaniel
Ash Framework What is Ash? Ash Framework is a declarative, resource-oriented application development framework for Elixir. A resource can...
New

Other popular topics Top

JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 55125 245
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 49266 226
New

We're in Beta

About us Mission Statement