Fix upload_attachments: specify file name in parameter dict#15
Fix upload_attachments: specify file name in parameter dict#15raph-topo wants to merge 1 commit intoricpol:mainfrom
upload_attachments: specify file name in parameter dict#15Conversation
Rationale: path on disk may not exist or may not be significant (as with `NamedTemporaryFile()`).
|
Non sure about this - a NamedTemporaryFile is just a file that happens to be managed by tempfile... but you may still get its path with "f.name". or - maybe I didn't understand what you are trying to do here? What use case do you have in mind? |
Yes, a random name, which it makes no sense to store in Grist. (But Pygrister
I'm using my pygrister fork including this PR to copy attachments from one Grist doc to another, without loosing their name: ...
for att in fr.attachments:
with NamedTemporaryFile() as file:
fr.grist.download_attachment(
filename=Path(file.name),
attachment_id=att.id,
)
to_id: int = to.grist.upload_attachments(
{att.fields.fileName: Path(file.name)}
)[1][0]
...(
|
Rationale: path on disk may not exist or may not be significant (as with
NamedTemporaryFile()).