cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X

How to send a file to AWS S3 via Content Loader Functions

Willie
16-Pearl

How to send a file to AWS S3 via Content Loader Functions

I am trying to send a file to an AWS S3 bucket via an API call.  I am able to send the file when I use Postman, but I am unable to send it via Content Loader Functions.  I am assuming my configurations may be incorrect.

 

When I send the file through Postman, I do the following:

  1. select PUT as the method
  2. paste the URL into the request URL (this automatically populates the parameters under Params tab)
  3. under the binary tab, select binary and the file to upload
  4. click on the Send button

The following is my service to send the file via Content Loader Functions:

// Content: BLOB
var Content =  Things["SystemRepository"].LoadBinary({
	path: "/directory/subDirectory/someFile.csv" /* STRING */
});

// result: BLOB
var result =  Resources["ContentLoaderFunctions"].PutBinary({
	proxyScheme: undefined /* STRING */,
	headers: undefined /* JSON */,
	ignoreSSLErrors: undefined /* BOOLEAN */,
	useNTLM: undefined /* BOOLEAN */,
	workstation: undefined /* STRING */,
	useProxy: undefined /* BOOLEAN */,
	proxyHost: undefined /* STRING */,
	url: "https://something.s3.amazonaws.com/888_2021-07-07_212149.457_UTC.csv?AWSAccessKeyId=ASIAXRXVK4ZJDEZAJJUX&Content-Type=text%2Fcsv&Expires=1625693809&Signature=nmDoq8o6NgidN1hUo583A72Nxi4%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEH4aCXVzLWVhc3QtMSJHMEUCIQDOPwJ3chYw%2BZAll8k4ZEqrvjQZBmXO1nld4ceraUPKOwIgeCWL5q%2FqLjxAYNjx%2FQEbF3lX2ib%2FhhHGAo1TAgAVevUqlAIIZhAAGgw1MTkxMzE4MTc1NTQiDK0Pq%2FgZhZxIAqJH%2FirxAaBuAJ0N1gMNL2RrTdXp8tO18LzWtjE6oTmjKqCP%2Fh8pY5Qld0zBk86AS15z3S70YiG%2FJ7XXyu6VSyc3rHpwLASoJ1ty%2FIBNIDldtkToG36xCPZAay3d0CEDHpkBRUpXNSEGDkaIncea99TrWnu9fR3jeCITp3u0JqJz%2FBP4WU6OCDmxGzJwgdloRXJsxA5YPKZBS9JRe7M15bhr839NZxWwMs9QDYk1kNkL0%2FicVeR%2FTxt0vXOAJdGFFJib%2FWbVyO9pBHjQp4HHJhzbbR%2FPYECgf%2FBmcDDXNow46uGHuMDyEnGsVfRPY4sM%2Fq2aaFT2rMEw7LWYhwY6mgFFj8ph881sLALSD7PX4wvnm2tGSDhr%2Ffn9vJ%2FtlQZCs8OS5mfzXgc7bEpupHXewZYDWEs3ro3uyFVvitA6JLibTsCj680yJzylbIuC8%2BjIvyRBbiy8Z9V6K2JRUCZEPSSmuAB%2FjkqYF%2Bx8Vrmn7vNJr3IafR10nEK5c2Aj%2Fgzr7VuWnKumd0PQTT2qZlOmSwS%2F6Y359gAVptF4" /* STRING */,
	content: Content /* BLOB */,
	timeout: undefined /* NUMBER */,
	proxyPort: undefined /* INTEGER */,
	password: undefined /* STRING */,
	domain: undefined /* STRING */,
	username: undefined /* STRING */
});

 

When I run this service, I get a blob output, but the file is not received in the S3 bucket. 

1 ACCEPTED SOLUTION

Accepted Solutions

Haven't done it myself and can't check atm, but I'd try to add headers (set the appropriate type there)

 

 

var headers = { 'Content-Type': 'application/json'};

 

and change headers: undefined /* JSON */ to headers: headers /* JSON */,

 

 

Also, what http response are you getting / what's is returned in result["result"]?

 

One more thing... While passing auth data in the URL seem to work, I'd consider using authorization headers for passing AWSAccessKeyId. You definitely have see this, but, just in case, there are some examples of using POST on Amazon https://docs.aws.amazon.com/AmazonS3/latest/userguide/HTTPPOSTExamples.html 

View solution in original post

2 REPLIES 2

Haven't done it myself and can't check atm, but I'd try to add headers (set the appropriate type there)

 

 

var headers = { 'Content-Type': 'application/json'};

 

and change headers: undefined /* JSON */ to headers: headers /* JSON */,

 

 

Also, what http response are you getting / what's is returned in result["result"]?

 

One more thing... While passing auth data in the URL seem to work, I'd consider using authorization headers for passing AWSAccessKeyId. You definitely have see this, but, just in case, there are some examples of using POST on Amazon https://docs.aws.amazon.com/AmazonS3/latest/userguide/HTTPPOSTExamples.html 

I was able to get it to work after setting headers to the following:

{ 'Content-Type': 'text/csv'},

Thank you!   In my case, it's 'text/csv' as that is the file type I am uploading.

Top Tags