Skip to main content

Module file_uploading

Module file_uploading 

Source
Expand description

Helper functions related to uploading to file storage.

Structsยง

AnswerUploadDestination
Who an answer upload is bound to, and where its objects are stored.
AuthorizationToken
Proof that an authorization check passed.
ExerciseServiceUpload
One stored upload, with the file details the iframeโ€™s wire result omits and the client APIโ€™s response carries.
ExerciseServiceUploadCleanup
Tracks uploaded object paths for cleanup when the batch fails.
ExerciseServiceUploadMetadata ๐Ÿ”’
ExerciseServiceUploadResultEntry
What an upload route returns for one stored file: the file_uploads row id an answer names it by, and the URL it can be fetched from.
StreamedExerciseServiceUpload
The parts of an upload that have reached the object store but have no database row yet.
UploadCleanup
Deletes the objects an upload has already stored, unless the upload got far enough to disarm it.

Enumsยง

UploadPathScheme
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 anyhow errors, and the running byte count of this part. Both are only meaningful once upload_stream has 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_uploads rows 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 field to the given path in 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-Length is within the limit of its X-File-Type, and the user teaches some course. The headers are the clientโ€™s claims; the stored size is not checked here.