-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create /api/v1/instance/:id/files/... api for basic CRUD operations #4357
Closed
7 tasks done
Tracked by
#4194
Labels
area:api
Work on the platform API
size:M - 3
Sizing estimation point
task
A piece of work that isn't necessarily tied to a specific Epic or Story.
Milestone
Comments
Closed
joepavitt
added
size:M - 3
Sizing estimation point
area:api
Work on the platform API
task
A piece of work that isn't necessarily tied to a specific Epic or Story.
labels
Aug 9, 2024
Have updated the description with an initial API spec to work from. This will be the basic structure used in the launcher as well. |
10 tasks
Updated with description of the |
Merged
4 tasks
I think there is an error in the sample above, each file object should have
should be
|
Task Completed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area:api
Work on the platform API
size:M - 3
Sizing estimation point
task
A piece of work that isn't necessarily tied to a specific Epic or Story.
The Frontend will make API requests to an API provided by the platform that then proxies the requests to the launcher to get the response.
As such, the semantics of the platform API will need to mirror that implemented in the launcher via FlowFuse/nr-launcher#273
/api/v1/projects/:instanceId/files/...
owner
andmember
roles - need to consider ifviewer
should have read-only access (ie list, but no rename/upload etc)API Endpoints
We already have a file-system-like API for the shared-library endpoints. That was largely duplicated from the Node-RED api for managing libraries. It has some drawbacks, so I don't want to blindly copy its approach.
Care must be given to (and tests to verify) handling of unexpected
/
\
and..
appearing in filenames/paths.GET /api/v1/projects/:instanceId/files/_/:path
- list files in a directoryPUT /api/v1/projects/:instanceId/files/_/:path
- update file/directory information (name/sharing info)POST /api/v1/projects/:instanceId/files/_/:path
- create directory/upload fileDELETE /api/v1/projects/:instanceId/files/_/:path
- delete directory/fileGET /api/v1/projects/:instanceId/files/_/:path
Get a directory listing of
:path
. The response will be a collection object and support pagination (as per https://flowfuse.com/docs/contribute/api-design/#pagination).This doesn't provide a recursive list - only the files/directories at
:path
(which will be relative to/data/storage
on the instance itself).files
has atype
field to identifyfile
vsdirectory
.file
type also havesize
directory
type might also haveshare
- meta data about how that folder is shared by Node-RED. Details belowIf
:path
is not a directory that can be listed, the api will return404
. This means this end point cannot be used to get the file contents - that'll be handled separately.PUT /api/v1/projects/:instanceId/files/_/:path
Update information about a file/directory. This will support the following tasks, based on the body received. This operations should be mutually exclusive.
Rename/Move
TBD: relative/absolute name
Update sharing options
Only valid for directory objects; cannot modify sharing properties of a
:path
that represents a file.POST /api/v1/projects/:instanceId/files/_/:path
Either create a directory or upload a file. I could be persuaded to separate these out somehow.. but for now...
Create directory
Content-type: application/json
:path
and must not contain..
or/
Create file
Content-type: multipart/form-data
file
containing the file dataDELETE /api/v1/projects/:instanceId/files/_/:path
Delete the file/directory.
share
settingThe
share
property contains the properties:root
: the relative url the folder should be shared from (refhttpStatic
in Node-RED configuration)In future it can include any other settings supported by Node-RED - but
root
is the minimum requirement.In the database, a new
ProjectSetting
will be used under the keystaticAssets
. This will be a single property containing information about all shared directories:With the above example, an instance that is at
https://nr1.example.com
will serve:/data/storage/dashboard/images
ashttps://nr1.example.com/static/images
/data/storage/tps-reports
ashttps://nr1.example.com/reports
So a file stored in
/data/storage/dashboard/images/header/logo.png
will be served ashttps://nr1.example.com/static/images/header/logo.png
The launcher will use this settings to set the
httpStatic
property of the Node-RED settings file. (PRs open for this - see task list below).Tasks
The text was updated successfully, but these errors were encountered: