Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File uploads should preserve the original filename when possible #538

Open
bjester opened this issue Nov 14, 2024 · 4 comments
Open

File uploads should preserve the original filename when possible #538

bjester opened this issue Nov 14, 2024 · 4 comments

Comments

@bjester
Copy link
Member

bjester commented Nov 14, 2024

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)

@bjester bjester changed the title File uploads should pass the original filename when possible File uploads should preserve the original filename when possible Nov 14, 2024
@codesage01
Copy link

can i contribute to this?

@MisRob
Copy link
Member

MisRob commented Dec 12, 2024

Hi @codesage01, welcome and thanks for volunteering! For several first contributions, please find an unassigned issue labeled as 'help wanted' - that's how we label issues that we have identified as suitable for volunteers. After having long-term experience with our codebases, if you're still interested in this one, you're welcome to message us and we are happy to consider.

@codesage01
Copy link

ok i will do ... further

@rtibbles
Copy link
Member

As I have been messing about with the File classes in ricecooker, I'm also not actually sure that this attribute ever gets set, except for Graphie files. It's most odd. I am making updates so that this info is persisted, so that we can get it into Studio in the first place, and then this issue can be resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants