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

Extract and supply file mimetype for DataFile upload #173

Closed
wants to merge 1 commit into from

Conversation

JR-1991
Copy link
Member

@JR-1991 JR-1991 commented Feb 2, 2024

Overview

In issue #171, it was reported that replacing data files was not working due to an incorrect mime-type being submitted. Specifically, when trying to replace a docx file, the pyDataverse library was supplying text/plain as the mime-type, which was causing the issue.

It appears that this error originated from Python's request library, which was failing to supply the correct mime-type upon upload and was falling back to text/plain. As a result, Dataverse rejected the replacement due to a different mime type being supplied than what already existed.

In order to resolve the issue, the proposed solution involves extending the post_request and determining the mime-types before initiating a POST request. For this purpose, the implementation employs Python's mimetypes library to predict the mimetype. Subsequently, the identified mime-type is passed to the request.post method. If the mime-type cannot be guessed, the method returns to the current implementation.

ToDos

  • Mimetype detection before POST request
  • Add test case for file replacement

Closes

Fixes #171

@JR-1991 JR-1991 added type:bug Something isn't working pkg:api api related activities prio:asap Fix as soon as possible status:wip Work in progress labels Feb 2, 2024
@JR-1991 JR-1991 self-assigned this Feb 2, 2024
@JR-1991 JR-1991 linked an issue Feb 2, 2024 that may be closed by this pull request
4 tasks
@JR-1991 JR-1991 mentioned this pull request Feb 2, 2024
4 tasks
@JR-1991 JR-1991 closed this Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg:api api related activities prio:asap Fix as soon as possible status:wip Work in progress type:bug Something isn't working
Projects
Development

Successfully merging this pull request may close these issues.

problem with replace_datafile
1 participant