# Refresh image after upload

**URL:** <https://community.forestadmin.com/t/refresh-image-after-upload/1197>\
**Category:** Help me!\
**Created:** [October 22, 2020, 8:42am UTC](https://community.forestadmin.com/t/refresh-image-after-upload/1197 "2020-10-22T08:42:41Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jonl](https://avatars.discourse-cdn.com/v4/letter/j/e5b9ba/32.png) [@jonl](https://community.forestadmin.com/u/jonl)\
**Post date:** [October 22, 2020, 8:42am UTC](https://community.forestadmin.com/t/refresh-image-after-upload/1197/1 "2020-10-22T08:42:41Z")

</div>

I’ve created a smart action that uploads an image to an S3 bucket. Everything is correct but I can’t get an image in a summary view to refresh after upload. It is based on the example provided in the docs.

What am I missing?

```javascript
router.post('/actions/upload-logo', permissionMiddlewareCreator.smartAction(), (req, res) => {
  // Get the current company id
  const partnerId = req.body.data.attributes.ids[0];

  // Get the values of the input fields entered by the admin user.
  const attrs = req.body.data.attributes.values;
  const image = attrs['Logo Image'];

  P.all([
    uploadLogo(partnerId, image),
  ])
    .then(() => {
      // Once the upload is finished, send a success message to the admin user in the UI.
      return res.send({ success: 'Logo has been uploaded.' });
    });
});

```

---

<div class="post-metadata">

**Author:** ![anon62739609](https://avatars.discourse-cdn.com/v4/letter/a/c2a13f/32.png) [@anon62739609](https://community.forestadmin.com/u/anon62739609)\
**Post date:** [October 22, 2020, 9:04am UTC](https://community.forestadmin.com/t/refresh-image-after-upload/1197/2 "2020-10-22T09:04:08Z")

</div>

Hi @jonl 👋 !

Where is that url ? On a relationship or on the current record ?

---

<div class="post-metadata">

**Author:** ![jonl](https://avatars.discourse-cdn.com/v4/letter/j/e5b9ba/32.png) [@jonl](https://community.forestadmin.com/u/jonl)\
**Post date:** [October 22, 2020, 9:05am UTC](https://community.forestadmin.com/t/refresh-image-after-upload/1197/3 "2020-10-22T09:05:28Z")

</div>

Current. I saw the examples to refresh relations but wasn’t able to find how to do it for current.

---

<div class="post-metadata">

**Author:** ![anon62739609](https://avatars.discourse-cdn.com/v4/letter/a/c2a13f/32.png) [@anon62739609](https://community.forestadmin.com/u/anon62739609)\
**Post date:** [October 22, 2020, 9:52am UTC](https://community.forestadmin.com/t/refresh-image-after-upload/1197/4 "2020-10-22T09:52:07Z")

</div>

Can you check your network tab. Normally a request is sent to refresh your record just after the action has replied. Is it the case ?

---

<div class="post-metadata">

**Author:** ![jonl](https://avatars.discourse-cdn.com/v4/letter/j/e5b9ba/32.png) [@jonl](https://community.forestadmin.com/u/jonl)\
**Post date:** [October 22, 2020, 10:21am UTC](https://community.forestadmin.com/t/refresh-image-after-upload/1197/5 "2020-10-22T10:21:26Z")

</div>

It does indeed.

Things that come to my mind:

- The name of the file is the same and therefore the URL path is the same.
- It’s being server from a CDN.

Could it be that the browser is not downloading the new image as the url is the same and it’s being cached? I’ve had this issue in the website and I’ve workaround this by adding a dummy query parameter with a timestamp to the image URL.

---

<div class="post-metadata">

**Author:** ![anon62739609](https://avatars.discourse-cdn.com/v4/letter/a/c2a13f/32.png) [@anon62739609](https://community.forestadmin.com/u/anon62739609)\
**Post date:** [October 22, 2020, 10:39am UTC](https://community.forestadmin.com/t/refresh-image-after-upload/1197/6 "2020-10-22T10:39:52Z")

</div>

Yes, I’m pretty sure that’s the issue. That is actually the issue on all website, when not updating an url it does keep the image in cache 😞 so the solutions are to either change the url or like you said add a dummy query parameter to the url (Just the one return no need to update it in DB)

---

<div class="post-metadata">

**Author:** ![jonl](https://avatars.discourse-cdn.com/v4/letter/j/e5b9ba/32.png) [@jonl](https://community.forestadmin.com/u/jonl)\
**Post date:** [October 22, 2020, 11:41am UTC](https://community.forestadmin.com/t/refresh-image-after-upload/1197/7 "2020-10-22T11:41:59Z")

</div>

Thanks for confirming.

I returned in the smart field the URL with a dummy query parameter and the new file is downloaded by the browser and shown appropriately in the UI.

Here the code for the smart field in case anyone has a similar scenario.

```javascript
fields: [{
    field: 'logo_smart',
    type: 'String',
    get: (record) => {
      if (record.logo)
      return 'https://website.url/'+record.logo+'?'+Date.now();
    },
  }

```
