Commit graph

14 commits

Author SHA1 Message Date
Gabriel Simmer 8fff6da76b Add support for custom endpoints and keys for S3. 2021-05-29 19:37:45 +01:00
Gabriel Simmer 550e722a53 Implement SendFile() and ObjectInfo() for S3.
Also removed a now useless parameter for file providers, which used to
be for writing directly to the HTTP response.
2021-05-29 10:48:32 +01:00
Gabriel Simmer b90abd8779 Remove old file path function. 2021-05-23 14:46:28 +01:00
Gabriel Simmer 54fe5f9c5c Simplify file serving from local or remote.
Prior, we would decide how to serve a file based on whether it was local
or remote at a router level. This moves everything to an io.Copy call in
the router with the Provider returning an io.Reader.
2021-05-23 14:43:27 +01:00
Gabriel Simmer ce4ee64509
Minor linting fixes & move to CircleCI/UPX orb.
Some minor linting fixes and general style/scope changes, which should
have no impact on the overall application. Also moved to the offical
CircleCI UPX Orb, rather than my own (which is still maintained by me).
2020-04-24 09:01:53 +01:00
Gabriel Simmer 5e85a600d8
Simplify file router, add documenting comments.
The file router was starting to get out of hand, so I've done my best to
simplify it and get ahead of more spaghetti. As part of this, tidied up
some other code and added some much-needed comments and constants to
make things more readable. ObjectInfo() is much more useful as well,
determing if a file exists, if it's a directory and the location.

Feeling other bits of the project can be simplified, but mostly been
focused on the file providers and associated router.
2020-04-15 23:19:33 +01:00
Gabriel Simmer 8db4a35994
Better handling of serving files, frontend tweaks.
Implemented a few new functions to handle the differences between local
and remote files - local files will be served (best it can be) with
ServeContent(), while remote files will be passed through from the
response body directly to the response writer. This isn't a very elegant
solution right now, but hoping to refactor this approach and simplify
the decision logic. However, serving files from local disks is much
better, including improvements to video files and generally better
handling of metadata.

Also some small tweaks to the frontned to align things a little nicer.
2020-04-15 12:16:27 +01:00
Gabriel Simmer e1b8c50d55
Delete files and create directories.
Added DELETE handler to files endpoint for deleting files and
directories, along with new handling for creating directories, as
specified with the `X-NAS-Type` header - if this is set to "directory",
a new directory is created with the path of the request. Otherwise, an
attempt to parse the file from form data is done as before.

Also added buttons to interact with the new functionality in the default
frontend.
2020-04-12 22:10:51 +01:00
Gabriel Simmer c28851fcc3
Tests & CI, io.Reader > Multipart file.
Making some improvements to the future maintainability of the project,
namely in the form of tests. Also implemented a new "dist" command to
the Makefile that packs up the binaries, and will eventually be expanded
to do more legwork when prepping for a release.

Updated file providers to use io.Reader over an explicit multipart file,
and removed the handler in favour of a plain filename, since that was
it's primary purpose.
2020-04-03 13:26:06 +01:00
Gabriel Simmer d86ed1233f
Implemented uploading for Backblaze & Disk (v1)
Implemented file uploading for both the disk and Backblaze providers.
Also implements a UI element and frontend logic for doing so from the
frontend.

Disk will write directly to disk, while the Backblaze provider will
attempt to stream the file from memory directly to the POST body. This
could introduce some problems down the line, so caching to disk then
uploading in the background may need to be implemented. It also
performs the final upload using a goroutine so the end client can
continue on it's merry way.

Backblaze proved a bit tricky to do, and considering switching to using
a library for managing Backblaze going forward.
2020-03-30 20:51:26 +01:00
Gabriel Simmer 49dba732d3
Implement Setup() function for providers, cleanup
Implemented a much-needed Setup() function for providers to implement,
which (as demonstrated in the backblaze provider) allows for
authentication in advance of needing to make calls to remote locations.
This could also be used to create a directory or perform some other
sanity check required for the provider to work. So far, haven't noticed
any performance impacts from this approach, besides not needing to auth
each time we make a request.
2020-03-21 00:31:24 +00:00
Gabriel Simmer c2171d00c9
io.Copy rather than ioutil.ReadAll
Should offer some speed boost, copying the file contents rather than
reading it all to memory then writing it back out. Should theoretically
be able to handle larger files as well, although some benchmarks
are TBD around filesize limits.
2020-03-19 10:13:38 +00:00
Gabriel Simmer ea1075cb5b
Rewrite file provider to proxy data download (rather than redirect)
Reworked the fileprovider to proxy data directly from the provider
rather than attempt to funkily redirect when needed, since it was overly
complex and wouldn't work well in the long run. Temporarily added "file"
as constant return for determining the filetype through Backblaze.

Added a Makefile to make life easier as well, and rewrote the README to
reflect the refactor/rewrite and new approach to providers.
2020-03-15 23:49:00 +00:00
Gabriel Simmer bf1f06b79c Refactoring file storage to enable different providers
Expanding this as we go, currently have POC Backblaze B2 support and
basic 'disk' provider as well. Still WIP, but functional for the most
part. Also moving to simplified YAML configuration.

Overall, simplifying things to be extensible down the line. Still work
to be done, but coming along nicely.
2020-02-24 18:07:47 +00:00