Expand description
Helper functions related to uploading to file storage.
Structsยง
- Answer
Upload Destination - Who an answer upload is bound to, and where its objects are stored.
- Authorization
Token - Proof that an authorization check passed.
- Exercise
Service Upload - One stored upload, with the file details the iframeโs wire result omits and the client APIโs response carries.
- Exercise
Service Upload Cleanup - Tracks uploaded object paths for cleanup when the batch fails.
- Exercise
Service ๐Upload Metadata - Exercise
Service Upload Result Entry - What an upload route returns for one stored file: the
file_uploadsrow id an answer names it by, and the URL it can be fetched from. - Streamed
Exercise Service Upload - The parts of an upload that have reached the object store but have no database row yet.
- Upload
Cleanup - Deletes the objects an upload has already stored, unless the upload got far enough to
disarmit.
Enumsยง
- Upload
Path Scheme - Where an uploadโs objects are stored, and what the upload route hands back for them.
Constantsยง
- EXERCISE_
UPLOAD_ ๐MAX_ BATCH_ BYTES - EXERCISE_
UPLOAD_ ๐MAX_ FILES - EXERCISE_
UPLOAD_ ๐MAX_ FILE_ BYTES
Functionsยง
- consume_
exercise_ ๐upload_ bytes - delete_
file_ from_ storage - generate_
audio_ ๐path - Generates a path for an audio file with the appropriate extension.
- generate_
file_ ๐path - Generates a path for a generic file with the appropriate extension based on its filename.
- generate_
image_ ๐path - Generates a path for an image file with the appropriate extension.
- limited_
exercise_ ๐upload_ stream - Returns a side channel for typed upload-limit errors because the stream yields
anyhowerrors, and the running byte count of this part. Both are only meaningful onceupload_streamhas returned: the count is still climbing while the stream is being consumed. - process_
exercise_ service_ upload - Processes a spec-file upload from an exercise service or the playground. This function assumes that any permission checks have already been made.
- record_
exercise_ service_ upload - Records the
file_uploadsrows for an already-streamed upload. - stream_
exercise_ service_ upload - Streams every multipart part to the object store, issuing no statements at all.
- upload_
certificate_ svg - upload_
field_ from_ cms - Processes an upload from CMS.
- upload_
field_ ๐to_ storage - Uploads the data from the multipart
fieldto the givenpathin file storage. - upload_
file_ from_ cms - Processes an upload from CMS.
- upload_
image_ for_ organization - Processes an upload for an organizationโs image.
- validate_
exercise_ ๐upload_ file_ count - validate_
exercise_ ๐upload_ filename - validate_
exercise_ ๐upload_ id - validate_
exercise_ ๐upload_ not_ empty - validate_
media_ ๐headers - Refuses a media upload unless it is multipart form data whose declared
Content-Lengthis within the limit of itsX-File-Type, and the user teaches some course. The headers are the clientโs claims; the stored size is not checked here.