# Creating Files API call

**URL:** <https://forums.losant.com/t/creating-files-api-call/3302>\
**Category:** Help\
**Tags:** experience\
**Created:** [September 30, 2020, 1:24pm UTC](https://forums.losant.com/t/creating-files-api-call/3302 "2020-09-30T13:24:47Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sreyams\_Jain1](https://avatars.discourse-cdn.com/v4/letter/s/b5e925/32.png) [@Sreyams\_Jain1](https://forums.losant.com/u/Sreyams_Jain1)\
**Post date:** [September 30, 2020, 1:24pm UTC](https://forums.losant.com/t/creating-files-api-call/3302/1 "2020-09-30T13:24:47Z")

</div>

I am trying to create a file store using API [https://api.losant.com/applications/](https://api.losant.com/applications/)/files. Once I get the AWS credentials, not sure as to how I can call the returned URL with AWS parameter file. I want to reference a file from my desktop folder. Can this be done in json body? Or is there a simpler way with an API to use the Losant AWS S3 PUT node

---

<div class="post-metadata">

**Author:** ![Heath](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/heath/32/3036_2.png) [@Heath](https://forums.losant.com/u/Heath)\
**Post date:** [September 30, 2020, 3:19pm UTC](https://forums.losant.com/t/creating-files-api-call/3302/3 "2020-09-30T15:19:55Z")

</div>

Hello @Sreyams_Jain1,

> Once I get the AWS credentials, not sure as to how I can call the returned URL with AWS parameter file.

Would you be able to provide more information about what URL you are referring to? How are you receiving AWS credentials?

> I want to reference a file from my desktop folder. Can this be done in json body?

You have a file on the desktop of your computer and are using Losant from a Web Browser, and you would like to reference that file in Losant? Do I understand this correctly?

> Or is there a simpler way with an API to use the Losant AWS S3 PUT node

Could you give me more information about your use case? I would love to know what you are trying to accomplish and what you would like the end solution to look like!

Thank you,  
Heath

---

<div class="post-metadata">

**Author:** ![Sreyams\_Jain1](https://avatars.discourse-cdn.com/v4/letter/s/b5e925/32.png) [@Sreyams\_Jain1](https://forums.losant.com/u/Sreyams_Jain1)\
**Post date:** [September 30, 2020, 3:37pm UTC](https://forums.losant.com/t/creating-files-api-call/3302/7 "2020-09-30T15:37:37Z")

</div>

Basically when I first issue the files HTTP API , I get back the AWS credentials like below  
key:  
Content-Type: image/jpeg  
bucket: [files.onlosant.com](http://files.onlosant.com)  
X-Amz-Algorithm: AWS4-HMAC-SHA256  
X-Amz-Credential:  
X-Amz-Date:  
Policy:  
X-Amz-Signature:

“url”: “[https://s3.us-west-2.amazonaws.com/files.onlosant.com](https://s3.us-west-2.amazonaws.com/files.onlosant.com)”,  
“fields”: {  
“key”: “”,  
“Content-Type”: “image/jpeg”,  
“bucket”: “[files.onlosant.com](http://files.onlosant.com)”,  
“X-Amz-Algorithm”: “AWS4-HMAC-SHA256”,  
“X-Amz-Credential”: “”,  
“X-Amz-Date”: “”,  
“Policy”: “”,  
“X-Amz-Signature”: “”  
Next step is to upload the file in question by an HTTP API to the url with all the above and adding “file” key like  
file : @filepath  
as a form-data. The file key is not working the way I am doing.

Question is there another way to do this using the AWS S3 PUT with an API and not using the node in the workflow

---

<div class="post-metadata">

**Author:** ![JuliaKempf](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/juliakempf/32/2446_2.png) [@JuliaKempf](https://forums.losant.com/u/JuliaKempf)\
**Post date:** [October 1, 2020, 2:27pm UTC](https://forums.losant.com/t/creating-files-api-call/3302/8 "2020-10-01T14:27:36Z")

</div>

Hi @Sreyams_Jain1,

Based on what you have described above, it sounds like you are trying to do one of two things:

- Attempting to create a file and store it in Losant, to then push it to AWS
- Pulling a file from AWS into Losant

Are either of these correct?

Additionally, you wrote `Basically when I first issue the files HTTP API`, could you link me to the documentation for the Files API you are utilizing?

Thanks!  
Julia

---

<div class="post-metadata">

**Author:** ![Sreyams\_Jain1](https://avatars.discourse-cdn.com/v4/letter/s/b5e925/32.png) [@Sreyams\_Jain1](https://forums.losant.com/u/Sreyams_Jain1)\
**Post date:** [October 1, 2020, 2:44pm UTC](https://forums.losant.com/t/creating-files-api-call/3302/9 "2020-10-01T14:44:25Z")

</div>

Hi Julia,

I am attempting to POST a file to LOSANT using api described at [https://docs.losant.com/rest-api/files/](https://docs.losant.com/rest-api/files/)

This returns an AWS credentials to actually upload the contents of the file. I have difficulty in this second part when I try to do this as another HTTP call.

I am not sure as to how to send the contents of the file with the file parameter.

I am NOT trying to pull the file from AWS

![image001.png](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/5/52bcf967b2026e397b36a8b7f1ed6e6145de12d2.png)

![image002.png](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/7/743bc7397cae0e5650ef1620550f4b0531ac8864.png)

![image001.jpg](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/2/2485d26919316b1d80aa60f5ca8e2cb5bc0275fe.jpeg)

---

<div class="post-metadata">

**Author:** ![Heath](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/heath/32/3036_2.png) [@Heath](https://forums.losant.com/u/Heath)\
**Post date:** [October 1, 2020, 3:36pm UTC](https://forums.losant.com/t/creating-files-api-call/3302/10 "2020-10-01T15:36:32Z")

</div>

@Sreyams_Jain1,

I did some searching around in the forums and found [this post](https://forums.losant.com/t/file-functionality/1017). Is what you are trying to do today different than what you were attempting in that post?

Please let me know, I want to make sure we can solve your problem!

Thank you,  
Heath

---

<div class="post-metadata">

**Author:** ![Sreyams\_Jain1](https://avatars.discourse-cdn.com/v4/letter/s/b5e925/32.png) [@Sreyams\_Jain1](https://forums.losant.com/u/Sreyams_Jain1)\
**Post date:** [October 1, 2020, 4:15pm UTC](https://forums.losant.com/t/creating-files-api-call/3302/12 "2020-10-01T16:15:57Z")

</div>

Yes Heath, That is correct.

As in that post, I was trying to do that via javascript with form-data etc.

Now, I am trying to see if I can do with a HTTP, I saw there is a AWS S3 PUT node. Is there an API way to do using that?

![image001.png](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/5/52bcf967b2026e397b36a8b7f1ed6e6145de12d2.png)

![image002.png](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/7/743bc7397cae0e5650ef1620550f4b0531ac8864.png)

![image001.jpg](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/2/2485d26919316b1d80aa60f5ca8e2cb5bc0275fe.jpeg)

---

<div class="post-metadata">

**Author:** ![Heath](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/heath/32/3036_2.png) [@Heath](https://forums.losant.com/u/Heath)\
**Post date:** [October 1, 2020, 6:03pm UTC](https://forums.losant.com/t/creating-files-api-call/3302/14 "2020-10-01T18:03:19Z")

</div>

@Sreyams_Jain1,

I’m with you now!

To do this, you would need to follow the instructions outlined previously. That is:

1. As you have done, request the upload from the Losant API.  
This returns a signed S3 URL
2. Then you would use HTTP to POST the file to that S3 URL.

Please let me know if this helps.

Thank you,  
Heath
