Skip to main content

Module file_uploading

Module file_uploading 

Source
Expand description

Helper functions related to uploading to file storage.

StructsΒ§

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Β§

FileType πŸ”’
StoreKind

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 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.
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_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_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.