We link to release notes for certain uploaded files.
Right now my solution is:
- sg.upload() to get id for new Attachment (parent attachment)
- sg.create() to get id for new web Attachment (child attachment)
- sg.update() to assign the new web Attachment to the parent attachment
But it feels a bit messy, so I’m curious:
No way to set arbitrary fields when executing sg.upload()
?
sg.upload()
is basically doing sg.create()
in the background right? But no way to fill in arbitrary fields like you do with sg.create()
? So there’s no way to combine my sg.upload()
and sg.update()
commands?
It’d be nice to provide the child Attachment when I’m creating the parent Attachment. Also noticed that when uploading by hand, file_extension
gets set automatically – but with the API it’s blank, so I have to do it in sg.update()
afterward?
edit: apparently file_extension
is read only so it’s just not functional when uploading via api? Not seeing any way to specify it with the upload command.
shotgun.Fault: API update() Attachment.file_extension is read only
Cleaner way to use sg.update()
for Attachments?
When doing sg.update(), I’m matching the fields returned when I find that field, so it’s something like
attachment_data = {
'url': f"<url_to_release_notes>",
'name': version,
"content_type":"None",
"link_type":"web",
"type":"Attachment",
"id":attachment_id
}
url
and name
were already defined when I created the web attachment, so I don’t like repeating them (haven’t tested what happens if I change them here – does it update the original attachment or does it get messy?). content_type
, link_type
, and type
are information that could also be derived from id
. I didn’t test all permutations but not including the url that was already defined when I created the attachment gave me an error: API update() invalid/missing url hash string 'url'
Is there a better way to tackle this?
Bonus question: in the shotgrid web UI, is there a way to view all attachments regardless of project (including files with no project)?