Pink #F06DF2
Black #02060D
Dark Blue #081226
Blue #04ADBF
Yellow #F2E307
Also fixed minor bug where first 512 bytes of files are sometimes cut
off when determining content type.
Theorectically, this means that the entire binary is now self contained,
minus the need for the config file. Ripped out the redundant static file
directives and root handler while I was at it.
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.
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).
Implemented a rudementary authentication method using Keycloak as the
IdP - still very barebones, but login does function. Next steps will
include a Docker Compose file (most likely) for managing this
integration. The application will work fine without setting up the
integration however, and will just throw a warning message. Setup should
be relatively self explanatory, but some documentation is TBD, along
with some automation when spinning up for the first time. Still not
super happy with the implementation.
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.
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.
This is a workaround for the CircleCI Docker image, and should be
removed soon-ish. Before patching, the `make_build_dir` Makefile command
would fail, producing a single directory rather than all 3.
Packing binaries and files in a more sane manner, which should make
distributing releases easier moving forward. Will likely replace the
NAS_VERSION variable with something more dynamic moving forward.
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.
Previously, spaces or other special characters in filenames were borked
because of how the filenames were passed through to the ViewFile
function - with escaped strings (%020 instead of " "). Added a
QueryUnescape call, and slightly tweaked the router to use a filename
rather than accessing var everytime.
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.
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.
Removed common package, since it was largely useless and instead
integrated what I could into the router package. Should simplify things
going forward, but we can always split this out later. Also completely
removed authentication for the time being - want to consider other
options for this.
Addressing a bug where the configuration would try to interpret the
provider name from the entry in the configuration, rather than the
explicit `provider`. Also removed background uploading from Backblaze
(was worth a shot).
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.
Ran into an issue when running on a Raspberry Pi - occaisonally, the
int size for the files being provided from Backblaze (which is in
bytes) will be too large. This is fixed by upgrading the int to int64.
As a part of this debugging process, I upgraded the error handling when
fetching the Backblaze file listing to actually print the errors rather
than failing silently.