# Generate file preview from urls

**URL:** https://meta.discourse.org/t/generate-file-preview-from-urls/295174
**Category:** Migration
**Tags:** uploads
**Created:** [February 13, 2024, 8:20am UTC](https://meta.discourse.org/t/generate-file-preview-from-urls/295174 "2024-02-13T08:20:27Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![maaatt](https://avatars.discourse-cdn.com/v4/letter/m/ecb155/32.png) [@maaatt](https://meta.discourse.org/u/maaatt)
#### Post date: [February 13, 2024, 8:20am UTC](https://meta.discourse.org/t/generate-file-preview-from-urls/295174/1 "2024-02-13T08:20:27Z")

</div>

I migrated a Joomla forum to discourse.  
I have a lot of posts with the text and the attachment with this raw field structure:  
“[https://my-server/media/kunena/attachments/user-id/file-name](https://my-server/media/kunena/attachments/user-id/file-name)”

I would like to convert it in a more pretty UI:

 ![Screenshot 2024-02-13 at 09.18.04](https://global.discourse-cdn.com/meta/original/4X/e/6/a/e6a46b875d0b676e57bea1c0242debbdef7320a9.png)

but I’m unable to do this via console (`post.save`).  
It’s possible only if I open the edit box for the message and save it again.

Someone has managed to achieve this?  
Thanks for you help.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [February 13, 2024, 4:07pm UTC](https://meta.discourse.org/t/generate-file-preview-from-urls/295174/2 "2024-02-13T16:07:14Z")

</div>

What I would do is modify the script to import those images as proper Discourse uploads.

If it’s too late for that, are these URLs on a line by themselves? Do the images show up if you do a “rebuild html”?

---

<div class="post-metadata">

### Author: ![maaatt](https://avatars.discourse-cdn.com/v4/letter/m/ecb155/32.png) [@maaatt](https://meta.discourse.org/u/maaatt)
#### Post date: [February 19, 2024, 1:20pm UTC](https://meta.discourse.org/t/generate-file-preview-from-urls/295174/3 "2024-02-19T13:20:34Z")

</div>

thanks, can you help me to understand how to create an upload via script for a post for example?

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [February 19, 2024, 1:37pm UTC](https://meta.discourse.org/t/generate-file-preview-from-urls/295174/4 "2024-02-19T13:37:16Z")

</div>

I think the vBulletin script does attachment uploads as do several others. Just grep they script directory for “upload”.
