Closed garrettjstevens closed 2 years ago
This will need a new endpoint "files," which to match the other modules can be created by running yarn dlx @nestjs/cli generate resource files
in the packages/apollo-collaboration-server/
directory.
This will also need a MongoDB schema that has:
interface File {
basename: string // the name of the file that was uploaded
checksum: number // or string, depending on hash used
type: 'text/x-gff3' | 'text/x-fasta' // depends on what kind of file was uploaded
}
There will be /files/fasta
and /files/gff3
endpoints. Users can POST a new file to those endpoints, GET a list of files, and GET a file with e.g. /files/fasta/507f1f77bcf86cd799439011
.
The location the files are saved to should be configurable in the ENV file. The file name that it is saved as internally should be the file ID, e.g. (See next comments for what the file name should be.)507f1f77bcf86cd799439011
, not the file name of the uploaded file.
One thing to clarify about this is that if the same file is uploaded multiple times (possibly with different names) it is only stored once, because it’s stored name is a hash of its contents.
Good point, I forgot about that. So the file name should be the hash, not the (MongoDB) file ID. I'll correct that in my above comment.
From discussion with @rbuels, add an endpoint for managing files, specifically at first a way to upload files. The user will supply a file and it will be saved to disk and the following information will be saved in MongoDB:
For example:
The file will be saved in a compressed format. The idea is that once a file is uploaded successfully, it can be referenced in change objects, perhaps looking something like this: