Expand description
Helper functions related to uploading to file storage.
StructsΒ§
- 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Β§
ConstantsΒ§
- DEFAULT_
FILE_ πSIZE_ LIMIT - EXERCISE_
UPLOAD_ πMAX_ BATCH_ BYTES - EXERCISE_
UPLOAD_ πMAX_ FILES - EXERCISE_
UPLOAD_ πMAX_ FILE_ BYTES - FILE_
SIZE_ πLIMITS
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.
- get_
size_ πlimit_ for_ mime - 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. - make_
filename_ πsafe - path π
- process_
exercise_ service_ upload - Processes an upload from an exercise service, an exercise iframe or a native client. 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_
file_ πto_ storage - upload_
file_ πto_ storage_ in_ existing_ transaction - 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 - Generates a path for an audio file with the appropriate extension.