A user, aaronrsiphone, seeks help migrating categories from a Discourse instance where they lack admin access, relying on an export that excludes attachments and images. They have API access to their categories but struggle with downloading attachments due to mismatched, randomized filenames between the export and the actual URLs served by the server. RGJ clarifies the difference between short and full URLs, pointing to resources for converting short URLs. aaronrsiphone later shares a working solution: converting short upload URLs to full ones using a script, placing the attachments in the tombstone directory, and running uploads:recover_from_tombstone to restore them on the new instance.
Our team has been operating as a guest on another Discourse instance. We are standing up our own Discourse instance and would like to migrate our categories from the existing instance to the new instance. We do not have admin access to the existing server but the admins are willing to do a category export for us. However this export does not contain any attachments or images. We do have api access to the existing instance but only to our categories. We do have admin access on the new instance.
Is it possible to migrate attachments and images using only the API for the existing instance?
I was looking at the exported json and the attachment file names are different randomized strings than what is served in the browser which makes reverse engineering the API to download attachments and images not as straight forward. Even if we could download all the attachments from the existing instance I am not sure how to add them to the new instance. This post makes me want to believe it is as easy as dropping them in to that location with the requirement that the filenames are identical to what is in the exported json but that doesn’t seem to work.
There appears to be no relationship in filenames. Given this information I can use the api to fetch the attachments that are not included in the export. But i am not sure what filename to give it and where to place it on the new server.
Once that is sorted out would it be possible to have the attachments appear on the rendered topics pages when loaded as before the migration.
Reporting back with a solution that works with a test instance that I have not tried on prod.
This is for future me to pass on to the team who will actually be doing the migration or anyone else who needs something similar.
Attachments should be given the long form name, which can be converted from the short form in the json via the python script in Converting short upload URLs to full URLs
Attachments should be placed in discourse/public/uploads/tombstone/default/original/
Then run uploads:recover_from_tombstone while in /var/discourse/