How to associate a new upload with a previous post via the API

AI-generated summary

akrherz is migrating content from Jive Cloud to Discourse and seeks to associate uploaded files with existing posts via the API. They initially consider manually updating the post_uploads PostgreSQL table, as the API doesn’t appear to support updating uploads for existing posts. fefrei suggests simply editing the post to include a link to the upload, noting that Discourse internally tracks such associations. akrherz expresses concern that Discourse might later delete unassociated uploads, but fefrei reassures them that this is standard user behavior and Discourse handles it internally. Ultimately, akrherz confirms that editing the post with a link works — the API automatically updates the post_uploads table, resolving their concern.

I am migrating a bunch of content from the Jive Cloud to my discourse. I used the existing jive_api.rb which does not do attachments, so I am attempting to manually associate uploads with currently existing posts within discourse.

Via the API, I don’t see a means to update a current post’s uploads. My thought to try is to add the uploads via the API and then manually update the post_uploads postgresql table to update the post’s associated uploads. Do you think this will work or am I missing some means via the API to make this happen?

thank you

Can’t you just edit the post to add a link to the file?

Thanks, I suppose, but I worry that discourse would then think that this upload has no associated content and would delete the upload after some period. Maybe it wouldn’t :slight_smile:

But that’s what normal users do: They just link to an attachment in a post. Discourse then internally stores that in its database :slight_smile:

awesome, it works and the API auto-updates the post_uploads table to give me warm fuzzies