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.
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.
Icons! Finally, signifying type of link without relying on colours. Also
added some margin to help alleviate strain from contrasting colours.
Fixed background-color of "NAS" home link maintaining white background.
Got some good pointers for how to layout directories, so took the chance
to add a nicer colour palette. May tweak this a little later down the
line, but blue = directory, red = file.
Frontend logic for routing was a bit broken when generating links for
directories, appending an extra / to the start. Resolved this to
properly link - interestingly, the file listing could still be served,
but the uploading was broken?
Also enforced regex for provider of directory listings and tidied up
some other string handling.
Implemented file upload progress to the frontend using XMLHttpRequests,
since fetch() doesn't offer this functionality right now. Bit of a
fragmented approach to requests in the codebase right now, but hope to
resolve this soon. Not styled at all either.
Also added some nifty commands to the Makefile for producing smaller
binaries using some compiler flags and upx, and requires upx to be
installed (make small and make small_pi).
Expanded the README with more up-to-date data and elaboration on
providers, which may have been a bit unclear before. Also added a few
configuration examples for each provider, with comments.
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.
Started work on a new basic frontend, with some magic code from
@tomhodgins (Tom Hodgins) for templating and processing data, which was
the primary purpose for considering a full-fledged JavaScript
framework. Fairly simple right now, with minimal "bling", and seems
"functional enough". Might need to consider options for using less or
no JS down the line if there is demand.
As part of this frontend, actually implemented route logic for fetching
a sorted list of providers (might be worth investigating whether
storing this final result in memory is worth the performance to memory
trade-off).
Also fixed a bug where adding "/" to the end of a provider name without
a file path would result in a 404. This was addressed with some Regex
filtering on the path that should be able to handle that matching.
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.