Creating Files API call

I am trying to create a file store using API 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

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

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
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”,
“fields”: {
“key”: “”,
“Content-Type”: “image/jpeg”,
“bucket”: “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

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

Hi Julia,

I am attempting to POST a file to LOSANT using api described at 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

image002.png

image001.jpg

@Sreyams_Jain1,

I did some searching around in the forums and found this post. 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

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

image002.png

image001.jpg

@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