# How to get all uploaded files of entity?

**URL:** <https://community.fibery.io/t/how-to-get-all-uploaded-files-of-entity/2053>\
**Category:** Get Help\
**Tags:** files\
**Created:** [September 24, 2021, 2:53pm UTC](https://community.fibery.io/t/how-to-get-all-uploaded-files-of-entity/2053 "2021-09-24T14:53:48Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Niraj\_Chourasia](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/niraj_chourasia/32/4084_2.png) [@Niraj\_Chourasia](https://community.fibery.io/u/Niraj_Chourasia)\
**Post date:** [September 24, 2021, 2:53pm UTC](https://community.fibery.io/t/how-to-get-all-uploaded-files-of-entity/2053/1 "2021-09-24T14:53:48Z")

</div>

Hi there,  
I have scenario to get all uploaded files of an entity and send public url of files to somewhere 3rd party for download. Let me know please how we can achieve it inside script.

Thanks

---

<div class="post-metadata">

**Author:** ![Chr1sG](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/chr1sg/32/3941_2.png) [@Chr1sG](https://community.fibery.io/u/Chr1sG)\
**Post date:** [September 24, 2021, 3:26pm UTC](https://community.fibery.io/t/how-to-get-all-uploaded-files-of-entity/2053/2 "2021-09-24T15:26:54Z")

</div>

Do you mean you want a script that will send the URLs to a 3rd party?

---

<div class="post-metadata">

**Author:** ![Viktar\_Zhuk](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/viktar_zhuk/32/1934_2.png) [@Viktar\_Zhuk](https://community.fibery.io/u/Viktar_Zhuk)\
**Post date:** [September 24, 2021, 3:29pm UTC](https://community.fibery.io/t/how-to-get-all-uploaded-files-of-entity/2053/3 "2021-09-24T15:29:54Z")

</div>

Hi [Niraj\_Chourasia](https://community.fibery.io/u/Niraj_Chourasia)

Fibery platform could not provide you with public (not authorized) url to a file. To achieve that you have to implement own proxy or provide api key to 3rd party.

As I see, there is no helper method for file-url in script env.

So here is a snippet that prints direct urls to all Entity Files, please change [your-acc.fibery.io](http://your-acc.fibery.io) to your account url

```auto
// Developer reference is at api.fibery.io/#action-buttons

// Fibery API is used to retrieve and update entities
const fibery = context.getService('fibery');

// affected entities are stored in args.currentEntities;
// to support batch actions they always come in an array
for (const entity of args.currentEntities) {
    // to get collection fields query the API and provide the list of fields
    const entityWithExtraFields = await fibery.getEntityById(entity.type, entity.id, ['Files']);

    for (const file of entityWithExtraFields.Files) {
        const fileWithSecret = await fibery.getEntityById("fibery/file", file.Id, ['secret']);
        console.log("https://" + "your-acc.fibery.io" + "/api/files/" + fileWithSecret.secret);
    }
    
}

// HTTP allows to send requests to external services
const http = context.getService('http');

/*
await http.postAsync('https://hooks.slack.com/services/YOUR_SLACK_URL', {
    body: {
        text: 'Successful success!'
    },
    headers: { 'Content-type': 'application/json' }
});
*/

```

---

<div class="post-metadata">

**Author:** ![Niraj\_Chourasia](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/niraj_chourasia/32/4084_2.png) [@Niraj\_Chourasia](https://community.fibery.io/u/Niraj_Chourasia)\
**Post date:** [September 25, 2021, 7:01am UTC](https://community.fibery.io/t/how-to-get-all-uploaded-files-of-entity/2053/4 "2021-09-25T07:01:42Z")

</div>

No i want a script to get all attached files url of the current enity when user click on action button.

---

<div class="post-metadata">

**Author:** ![Chr1sG](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/chr1sg/32/3941_2.png) [@Chr1sG](https://community.fibery.io/u/Chr1sG)\
**Post date:** [September 25, 2021, 8:06am UTC](https://community.fibery.io/t/how-to-get-all-uploaded-files-of-entity/2053/5 "2021-09-25T08:06:16Z")

</div>

> [@Viktar\_Zhuk](#):
>
> Fibery platform could not provide you with public (not authorized) url to a file.

You can get URLs in the way suggested by @Viktar_Zhuk but access to the files requires authorisation.

---

<div class="post-metadata">

**Author:** ![Niraj\_Chourasia](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/niraj_chourasia/32/4084_2.png) [@Niraj\_Chourasia](https://community.fibery.io/u/Niraj_Chourasia)\
**Post date:** [September 25, 2021, 8:34am UTC](https://community.fibery.io/t/how-to-get-all-uploaded-files-of-entity/2053/6 "2021-09-25T08:34:54Z")

</div>

even yes i need to send files to 3rd party

---

<div class="post-metadata">

**Author:** ![Niraj\_Chourasia](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/niraj_chourasia/32/4084_2.png) [@Niraj\_Chourasia](https://community.fibery.io/u/Niraj_Chourasia)\
**Post date:** [September 25, 2021, 8:35am UTC](https://community.fibery.io/t/how-to-get-all-uploaded-files-of-entity/2053/7 "2021-09-25T08:35:51Z")

</div>

How i can provide authorisation for file?

---

<div class="post-metadata">

**Author:** ![Viktar\_Zhuk](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/viktar_zhuk/32/1934_2.png) [@Viktar\_Zhuk](https://community.fibery.io/u/Viktar_Zhuk)\
**Post date:** [September 27, 2021, 10:08am UTC](https://community.fibery.io/t/how-to-get-all-uploaded-files-of-entity/2053/8 "2021-09-27T10:08:23Z")

</div>

It is an ordinary API call, you have to add Authorization header to HTTP request see [download file api](https://api.fibery.io/#download-file)

```auto
curl -X GET https://YOUR_ACCOUNT.fibery.io/api/files/FILE_SECRET \
     -H 'Authorization: Token YOUR_TOKEN'

```

---

<div class="post-metadata">

**Author:** ![Niraj\_Chourasia](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/niraj_chourasia/32/4084_2.png) [@Niraj\_Chourasia](https://community.fibery.io/u/Niraj_Chourasia)\
**Post date:** [September 29, 2021, 10:17am UTC](https://community.fibery.io/t/how-to-get-all-uploaded-files-of-entity/2053/9 "2021-09-29T10:17:38Z")

</div>

Thank you it’s worked
