# Store and access external file from binary

**URL:** <https://community.postman.com/t/store-and-access-external-file-from-binary/63921>\
**Category:** Help Hub\
**Tags:** variables\
**Created:** [July 10, 2024, 2:08pm UTC](https://community.postman.com/t/store-and-access-external-file-from-binary/63921 "2024-07-10T14:08:24Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![davidronen](https://avatars.discourse-cdn.com/v4/letter/d/9d8465/32.png) [@davidronen](https://community.postman.com/u/davidronen)\
**Post date:** [July 10, 2024, 2:08pm UTC](https://community.postman.com/t/store-and-access-external-file-from-binary/63921/1 "2024-07-10T14:08:24Z")

</div>

Hi  
I am using Postman ‘POST’ request to send a file which is uploaded to the request body from binary - see screenshot below.  
Now I need a way to store the file so that I can access it and compare its content to the content in a response to a respective call to ‘GET’, for test purposes.  
Is there a way to achieve that?

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/6/5/65cf42835e55e2ae93a633169a8216b9e06099db.png)

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [July 10, 2024, 3:48pm UTC](https://community.postman.com/t/store-and-access-external-file-from-binary/63921/2 "2024-07-10T15:48:52Z")

</div>

Hey @davidronen 👋

Welcome to the Postman Community! :postman:

You will not be able to access and read content from a file, in your local file system using Postman.

Files can be attached to requests for certain scenarios but you wouldn’t be about to directly read the contents of any file and compare that with a response via the UI.

---

<div class="post-metadata">

**Author:** ![davidronen](https://avatars.discourse-cdn.com/v4/letter/d/9d8465/32.png) [@davidronen](https://community.postman.com/u/davidronen)\
**Post date:** [July 11, 2024, 6:27am UTC](https://community.postman.com/t/store-and-access-external-file-from-binary/63921/3 "2024-07-11T06:27:25Z")

</div>

Hi Danny,  
Thanks a lot for your response.  
I was under the impression that it will be possible to do something like:

1. Upload the file from binary (as shown in my previous post), then
2. Get the content , e.g. as echo the content to a String, then
3. Take the String and do something like:

```auto
var body_str = getFileContentInSomeWay();
var requestAsJson = JSON.parse(body_str);
pm.environment.set('request_body', body_str);
pm.collectionVariables.set('var_name',requestAsJson);

```

Am I way off?

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [July 11, 2024, 6:51am UTC](https://community.postman.com/t/store-and-access-external-file-from-binary/63921/4 "2024-07-11T06:51:10Z")

</div>

You could do it that way using some kind of echo service but it would be a workaround and I’m not 100% sure that it would be a 1:1 comparison. 🤔

You’d also be introducing an extra call to that service, only to echo the content. Failing that, you could probably be this in a script using your favorite language.

It’s worth experimenting for sure 😃

---

<div class="post-metadata">

**Author:** ![davidronen](https://avatars.discourse-cdn.com/v4/letter/d/9d8465/32.png) [@davidronen](https://community.postman.com/u/davidronen)\
**Post date:** [July 11, 2024, 6:59am UTC](https://community.postman.com/t/store-and-access-external-file-from-binary/63921/5 "2024-07-11T06:59:10Z")

</div>

OK, so no “ready (and easy) to use” function/library for that… (?)  
Wired.  
Thanks 🙂

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [July 11, 2024, 7:04am UTC](https://community.postman.com/t/store-and-access-external-file-from-binary/63921/6 "2024-07-11T07:04:15Z")

</div>

Postman has never had direct access to read the contents of the files from your file directory, using the scripting environment.

There are certain places in the platform that allow you to use specific data files but that’s about it.

---

<div class="post-metadata">

**Author:** ![davidronen](https://avatars.discourse-cdn.com/v4/letter/d/9d8465/32.png) [@davidronen](https://community.postman.com/u/davidronen)\
**Post date:** [July 11, 2024, 7:56am UTC](https://community.postman.com/t/store-and-access-external-file-from-binary/63921/7 "2024-07-11T07:56:22Z")

</div>

The testcase scenario is as follows:

1. ‘POST’ some data (I chose to do that by uploading a ready file as binary in the ‘POST’ request body).
2. The application does some computations on the data and stores it.
3. Verify that the stored data is correct after the computations. I thought of using a ‘GET’ call and comparing the ‘POST’ values with the ‘GET’ values.

I have access to the posted data if I create the payload within a pre-request script. However this is tedious, especially since the requested data is already automatically generated into a file, which I then upload into the ‘POST’ request body.  
I hoped that Postman will have a way to read the payload into a variable, so that comparison is easily done within a post-request ( `pm.test()` ) in the ‘GET’ call.  
Apparently no such way…(?)

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/system/32/29796_2.png) [@system](https://community.postman.com/u/system)\
**Post date:** [August 10, 2024, 7:57am UTC](https://community.postman.com/t/store-and-access-external-file-from-binary/63921/8 "2024-08-10T07:57:05Z")

</div>

Closed on August 10, 2024, 7:57am UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
