Skip to content

File uploads should preserve the original filename when possible #538

Description

@bjester

Observed behavior

When requesting a file upload URL from Studio, Ricecooker does utilize the original file name, but that is eventually discarded, meaning the filename for cheffed files will default to file

the issue is that ricecooker's implementation of the file upload URL stuff [...] creates the file object to get the upload URL, but then an entirely new file object gets created during the channel upload, so that data gets discarded.

Expected behavior

Ricecooker should use preserve the filename

User-facing consequences

These files end up showing Unknown filename to the end user.

Context

learningequality/studio#4814

Looking at the following bit of code it does appear Ricecooker passes the filename along in its initial request for an upload URL, but according to the above quote, that gets discarded

"name": file_data.original_filename or file_data.get_filename(),
"file_format": file_data.extension,
"preset": file_data.get_preset(),
"duration": file_data.duration,
}
# Workaround for a bug in the Studio upload URL endpoint, whereby
# it does not currently use the passed in file_format as the default
# extension.
name, ext = os.path.splitext(data["name"])
if not ext:
data["name"] = "{}.{}".format(name, data["file_format"])
url_response = config.SESSION.post(config.get_upload_url(), json=data)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions