Modify "created_by" during attachment upload

In order to create an attachment via the Python API we need to use the upload() method (API Reference — python-api v3.4.1 documentation).

I have a tool to create notes and attachments, and we can populate the user field on the note, but I can’t figure out how to change the the created_by field during attachment creation (upload()). So the note created will have the correct user, but the associated attachment will be created_by the api script rather than the user. This prevents the attachment from showing inline when displaying notes.

I’m wondering if there is a way to manage the created_by field when creating / uploading an attachment.

I’m using this method from @tony : Shotgun API Tips and Tricks Megapost - #4 by tony

And this method for file naming from @bouchep : Note attachment with frame number - Python API

Have you tried authentiating using a session token or by using the sudo_as_login option in the Shotgun api class?

I’ve tried sudo_as_login but it causes an error when doing an upload(). My guess is that sudo_as_login is not allowed for upload().

In any case, the note/attachment creator is not always an SG HumanUser. They are sometimes Groups or ClientUsers, so I don’t think session tokens or sudo_as_login would work.

Can you provide a screenshot of this?

Here’s how inline notes look (attachment created_by and created_on matches the associated note):

Here’s how it looks if attachment created_by does not match the associated note user:

1 Like

Wonder if it works via the REST api…

I checked REST API: I’m pretty sure it has the same options. There are three parts to the upload process:

  1. Request an upload URL.
  2. Upload the files to url returned.
  3. Send the data needed to link the file to a record or field on a record.

Part 3 is where you would populate fields, but the only options are display_name and “tags” (same as Python API):

“upload_data” - This object contains the values to update on an Attachment after it is created and linked. The two available keys are “display_name” and “tags”. For thumbnail uploads this should be an empty object.

1 Like

There must be a way to do it but maybe its not exposed.
Best to log an ticket for this!

1 Like

Hi Stavernia,
I am also trying to upload multiple attachments(Annotations) to version (in a single widget) like above. Could you please provide the code which you had written for above uploaded images on shotgun.
Thanks in Advance