Skip to content

Enable to create a static resource from a URL#26

Open
Pierlou wants to merge 4 commits intomainfrom
feat/upload-from-url
Open

Enable to create a static resource from a URL#26
Pierlou wants to merge 4 commits intomainfrom
feat/upload-from-url

Conversation

@Pierlou
Copy link
Copy Markdown
Collaborator

@Pierlou Pierlou commented Sep 4, 2025

We could also retrieve/build file_name and mime from the URL's headers, but it sounds safer to ask the user to fill them in, idk 🤔

@Pierlou Pierlou requested a review from maudetes September 4, 2025 13:15
Comment thread datagouv/resource.py
)
with self._client.session.stream("GET", file_to_upload) as streamed:
streamed.raise_for_status()
streamed.read()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the .read()?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is apparently the syntax for httpx

Comment thread datagouv/resource.py
raise ValueError(
"When uploading from a URL, file_name and mime arguments are required."
)
with self._client.session.stream("GET", file_to_upload) as streamed:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we open/close the session stream without a with context in order to mutualise the POST logic with just a different files dict?

Comment thread README.md
@Pierlou Pierlou changed the title Enable creating a static resource from a URL Enable to create a static resource from a URL Feb 27, 2026
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

Successfully merging this pull request may close these issues.

2 participants