# Getting image urls uploaded from @forestadmin/plugin-aws-s3

**URL:** https://community.forestadmin.com/t/getting-image-urls-uploaded-from-forestadmin-plugin-aws-s3/7332
**Category:** Help me!
**Created:** [July 17, 2024, 2:16pm UTC](https://community.forestadmin.com/t/getting-image-urls-uploaded-from-forestadmin-plugin-aws-s3/7332 "2024-07-17T14:16:24Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![Quentin\_Farizon](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/quentin_farizon/32/7146_2.png) [@Quentin\_Farizon](https://community.forestadmin.com/u/Quentin_Farizon)
#### Post date: [July 17, 2024, 2:16pm UTC](https://community.forestadmin.com/t/getting-image-urls-uploaded-from-forestadmin-plugin-aws-s3/7332/1 "2024-07-17T14:16:24Z")

</div>

## Feature(s) impacted

I have successfully setup uploading files to S3 from ForestAdmin, using :

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/9/96d7b6579cdeaeb5e85eaa88e104ca66fd986b18.png)

## Observed behavior

But when I list it in Forestadmin, I get this strange url with code in it :

 ![Screenshot from 2024-07-17 15-37-00](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/3/319039ae72c9e92a953ec63f326a0c359a968ad5.png)

## Expected behavior

I’d like the image to be displayed, or at least a correct url

## Failure Logs

## Context

- Project name: Certainty
- Team name: Certainty
- Environment name: Preprod
- Agent technology: nodejs
- 

```
"@forestadmin/agent": "1.38.12",

```

“@forestadmin/datasource-sequelize”: “1.8.1”,  
“@forestadmin/plugin-aws-s3”: “1.3.72”,
- Database type: pg

---

<div class="post-metadata">

### Author: ![anon7311026](https://avatars.discourse-cdn.com/v4/letter/a/f9ae1b/32.png) [@anon7311026](https://community.forestadmin.com/u/anon7311026)
#### Post date: [July 17, 2024, 2:23pm UTC](https://community.forestadmin.com/t/getting-image-urls-uploaded-from-forestadmin-plugin-aws-s3/7332/2 "2024-07-17T14:23:33Z")

</div>

Hello @Quentin_Farizon, welcome to the community.  
Can you please check directly in your database what does the data look like ? Is it only the aws url ? or do you have code as well ?  
To me it looks like the code + url is stored in your database.  
If this is the case, there might be an issue with the upload, rather than the list.

---

<div class="post-metadata">

### Author: ![Quentin\_Farizon](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/quentin_farizon/32/7146_2.png) [@Quentin\_Farizon](https://community.forestadmin.com/u/Quentin_Farizon)
#### Post date: [July 17, 2024, 2:27pm UTC](https://community.forestadmin.com/t/getting-image-urls-uploaded-from-forestadmin-plugin-aws-s3/7332/3 "2024-07-17T14:27:40Z")

</div>

In the database I have the result of the storeAt function I provided :  
 ![image](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/6/67896d3a5cabe56cf625aa5cadcb919512c58acb.png)

---

<div class="post-metadata">

### Author: ![anon7311026](https://avatars.discourse-cdn.com/v4/letter/a/f9ae1b/32.png) [@anon7311026](https://community.forestadmin.com/u/anon7311026)
#### Post date: [July 17, 2024, 2:31pm UTC](https://community.forestadmin.com/t/getting-image-urls-uploaded-from-forestadmin-plugin-aws-s3/7332/4 "2024-07-17T14:31:41Z")

</div>

Ok,  
Did you configure anything in the widgets ([edit and display](https://docs.forestadmin.com/user-guide/collections/customize-your-fields)) for the Logo field in the frontend ?  
There are options to add prefixes for files in here, so that could be your issue.

---

<div class="post-metadata">

### Author: ![Quentin\_Farizon](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/quentin_farizon/32/7146_2.png) [@Quentin\_Farizon](https://community.forestadmin.com/u/Quentin_Farizon)
#### Post date: [July 18, 2024, 9:49am UTC](https://community.forestadmin.com/t/getting-image-urls-uploaded-from-forestadmin-plugin-aws-s3/7332/5 "2024-07-18T09:49:52Z")

</div>

Nothing configured no

---

<div class="post-metadata">

### Author: ![anon7311026](https://avatars.discourse-cdn.com/v4/letter/a/f9ae1b/32.png) [@anon7311026](https://community.forestadmin.com/u/anon7311026)
#### Post date: [July 18, 2024, 10:19am UTC](https://community.forestadmin.com/t/getting-image-urls-uploaded-from-forestadmin-plugin-aws-s3/7332/6 "2024-07-18T10:19:08Z")

</div>

Ok.

Could you try setting up a prefix using the [widget file display config](https://docs.forestadmin.com/user-guide/collections/customize-your-fields/display-widgets#prefix) so that the frontend can access the image as the correct url ?

---

<div class="post-metadata">

### Author: ![Quentin\_Farizon](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/quentin_farizon/32/7146_2.png) [@Quentin\_Farizon](https://community.forestadmin.com/u/Quentin_Farizon)
#### Post date: [July 18, 2024, 2:49pm UTC](https://community.forestadmin.com/t/getting-image-urls-uploaded-from-forestadmin-plugin-aws-s3/7332/7 "2024-07-18T14:49:05Z")

</div>

But without any widget configuration, why is it not returning the raw text ? Do you have some documentation on what the plugin-aws-s3 does on get/list ?

---

<div class="post-metadata">

### Author: ![Quentin\_Farizon](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/quentin_farizon/32/7146_2.png) [@Quentin\_Farizon](https://community.forestadmin.com/u/Quentin_Farizon)
#### Post date: [July 18, 2024, 3:06pm UTC](https://community.forestadmin.com/t/getting-image-urls-uploaded-from-forestadmin-plugin-aws-s3/7332/8 "2024-07-18T15:06:45Z")

</div>

I have tried setting widget file with my prefix [https://certainty-preprod.s3.eu-west-3.amazonaws.com](https://certainty-preprod.s3.eu-west-3.amazonaws.com)

But it is adding it twice : [https://certainty-preprod.s3.eu-west-3.amazonaws.com/https://certainty-preprod.s3.eu-west-3.amazonaws.com/public/VendorCompany/tLa9mbJqQhC0smOw.jpeg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIA2UC26O7DR4N2LMYF%2F20240718%2Feu-west-3%2Fs3%2Faws4\_request&X-Amz-Date=20240718T150438Z&X-Amz-Expires=300&X-Amz-Signature=d2f465459bc7213bfa011833d7d298fb4f81eaec32a2795f9edc88be69dc5699&X-Amz-SignedHeaders=host&x-id=GetObject](https://certainty-preprod.s3.eu-west-3.amazonaws.com/https://certainty-preprod.s3.eu-west-3.amazonaws.com/public/VendorCompany/tLa9mbJqQhC0smOw.jpeg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIA2UC26O7DR4N2LMYF%2F20240718%2Feu-west-3%2Fs3%2Faws4_request&X-Amz-Date=20240718T150438Z&X-Amz-Expires=300&X-Amz-Signature=d2f465459bc7213bfa011833d7d298fb4f81eaec32a2795f9edc88be69dc5699&X-Amz-SignedHeaders=host&x-id=GetObject)

---

<div class="post-metadata">

### Author: ![Quentin\_Farizon](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/quentin_farizon/32/7146_2.png) [@Quentin\_Farizon](https://community.forestadmin.com/u/Quentin_Farizon)
#### Post date: [July 18, 2024, 3:52pm UTC](https://community.forestadmin.com/t/getting-image-urls-uploaded-from-forestadmin-plugin-aws-s3/7332/9 "2024-07-18T15:52:58Z")

</div>

I have tried disabling the customization with plugin-aws-s3, and the reading works fine now :

- with widget text, I get the raw key path from my db
- with widget file + prefix, my images are displayed

---

<div class="post-metadata">

### Author: ![anon7311026](https://avatars.discourse-cdn.com/v4/letter/a/f9ae1b/32.png) [@anon7311026](https://community.forestadmin.com/u/anon7311026)
#### Post date: [July 19, 2024, 5:16am UTC](https://community.forestadmin.com/t/getting-image-urls-uploaded-from-forestadmin-plugin-aws-s3/7332/10 "2024-07-19T05:16:37Z")

</div>

I believe I have found the root of the issue in the `@forestadmin/plugin-aws-s3` package.  
A fix is on the way.

---

<div class="post-metadata">

### Author: ![Quentin\_Farizon](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/quentin_farizon/32/7146_2.png) [@Quentin\_Farizon](https://community.forestadmin.com/u/Quentin_Farizon)
#### Post date: [July 19, 2024, 8:55am UTC](https://community.forestadmin.com/t/getting-image-urls-uploaded-from-forestadmin-plugin-aws-s3/7332/11 "2024-07-19T08:55:23Z")

</div>

Thinking about it, it would make sense for me to presign url myself, in a model hook (I have plugged FA onto Sequelize), so that both ForestAdmin retrieval and standard retrieval have the same mechanism. In this context, maybe the plugin should have a readMode: ‘passthrough’ (or “ignore” ? or “bypass” ?) that sends the value as-is.

I’ve patched it, it works well !

Here is the patch :

```javascript
diff --git a/node_modules/@forestadmin/plugin-aws-s3/dist/field/create-field.js b/node_modules/@forestadmin/plugin-aws-s3/dist/field/create-field.js
index 7bdd348..69ec1e2 100644
--- a/node_modules/@forestadmin/plugin-aws-s3/dist/field/create-field.js
+++ b/node_modules/@forestadmin/plugin-aws-s3/dist/field/create-field.js
@@ -17,6 +17,9 @@ function createField(collection, config) {
             key = config.objectKeyFromRecord?.mappingFunction
                 ? await config.objectKeyFromRecord.mappingFunction(record, context)
                 : key;
+ if (config.readMode === 'passthrough') {
+ return key
+ }
             if (config.readMode === 'proxy') {
                 return (0, data_uri_1.encodeDataUri)(await config.client.load(key));
             }
diff --git a/node_modules/@forestadmin/plugin-aws-s3/dist/types.d.ts b/node_modules/@forestadmin/plugin-aws-s3/dist/types.d.ts
index 253e95f..2d34023 100644
--- a/node_modules/@forestadmin/plugin-aws-s3/dist/types.d.ts
+++ b/node_modules/@forestadmin/plugin-aws-s3/dist/types.d.ts
@@ -64,7 +64,7 @@ export type Options<S extends TSchema = TSchema, N extends TCollectionName<S> =
      * dealing with small files and are behind an entreprise proxy which forbids direct
      * access to S3.
      */
- readMode?: 'url' | 'proxy';
+ readMode?: 'url' | 'proxy' | 'passthrough';
     /**
      * Which ACL to use on the uploaded objects.
      * Default is "private" (urls will be signed so that the files can be reached from the frontend).

```

---

<div class="post-metadata">

### Author: ![anon7311026](https://avatars.discourse-cdn.com/v4/letter/a/f9ae1b/32.png) [@anon7311026](https://community.forestadmin.com/u/anon7311026)
#### Post date: [July 19, 2024, 9:41am UTC](https://community.forestadmin.com/t/getting-image-urls-uploaded-from-forestadmin-plugin-aws-s3/7332/12 "2024-07-19T09:41:11Z")

</div>

Hello @Quentin_Farizon,

I’m glad that you have found a solution that works for you.  
If you need it, the [fix for the plugin](https://github.com/ForestAdmin/agent-nodejs/releases/tag/%40forestadmin%2Fplugin-aws-s3%401.3.80) is live now.  
Please mark this post as solved 🙏

---

<div class="post-metadata">

### Author: ![Quentin\_Farizon](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/quentin_farizon/32/7146_2.png) [@Quentin\_Farizon](https://community.forestadmin.com/u/Quentin_Farizon)
#### Post date: [July 19, 2024, 2:27pm UTC](https://community.forestadmin.com/t/getting-image-urls-uploaded-from-forestadmin-plugin-aws-s3/7332/13 "2024-07-19T14:27:33Z")

</div>

Ok, the fix makes sense 🙂  
I may have to use passthrough or not, depending on the use case.

Would you consider adding passthrough mode in the library ? Maintaining a patch isn’t ideal, and I’m sure this would be useful for others (and easily documented)

---

<div class="post-metadata">

### Author: ![anon7311026](https://avatars.discourse-cdn.com/v4/letter/a/f9ae1b/32.png) [@anon7311026](https://community.forestadmin.com/u/anon7311026)
#### Post date: [July 22, 2024, 9:45am UTC](https://community.forestadmin.com/t/getting-image-urls-uploaded-from-forestadmin-plugin-aws-s3/7332/14 "2024-07-22T09:45:12Z")

</div>

Hello @Quentin_Farizon,

The `@forestadmin/plugin-aws-s3` repository is open source: would you be willing to make a pull request with your suggestion ? It will be reviewed and integrated in mainline if ok.  
Thanks !
