Example 1: File Upload
Step 1:
From the SAS Intelligent Advertising for Publishers user interface, go to Admin > Users to retrieve your user API key located in the "API Key" field.
Step 2:
Using the cURL utility, retrieve the signed URL that will give you access to upload a file. In this example, it is "test4.txt" which is a CSV file.
curl -v -H "Content-Type: text/plain" -X GET "https://<short_name>.aimatch.com/ads/getURLForUploading.xml?api_key=<api key>&name=test/text4.txt"
NOTES:
- Do not use a leading slash in the file path.
- Directories included in the path that do not exist will be created under the PUBLIC directory in S3.
- Make sure the content type that is specified in the header matches the content type of the file to be uploaded. The default is "Content-Type: text/plain."
You should receive the following response, including the lines in bold below:
* Trying <IP address>...
* TCP_NODELAY set
* Connected to <short_name>.aimatch.com (<IP address>) port <port number>
* TLS 1.2 connection using <connection information>
* Server certificate: *.aimatch.com
* Server certificate: <server certificate>
> GET /ads/getURLForUploading.xml?api_key=<api key>&name=test/text4.txt HTTP/1.1
> Host: <short_name>.aimatch.com
> User-Agent: curl/7.54.0
> Accept: */*
> Content-Type: text/plain
>
< HTTP/1.1 200 OK
< Date: <request date>
< Content-Type: application/xml; charset=utf-8
< Transfer-Encoding: chunked
Connection: keep-alive
< Status: 200 OK
< Strict-Transport-Security: max-age=631152000; includeSubdomains; preload
< Cache-Control: no-cache, no-store
< Pragma: no-cache
< Set-Cookie: _sasia_ssl_session=<session ID>; path=/; secure; HttpOnly; SameSite=<site>
< X-Request-Id: <request ID>
< X-Runtime: 0.095368
< X-Rack-Cache: miss
< Content-Security-Policy: default-src https:; base-uri 'self'; block-all-mixed-content; child-src *; connect-src https: wss:; font-src https: data:; form-action 'self' https:; frame-ancestors 'self'; img-src https:; media-src https:; object-src https:; plugin-types application/x-shockwave-flash application/pdf; script-src 'unsafe-inline' 'unsafe-eval' https:; style-src 'unsafe-inline' 'unsafe-eval' https:
< Referrer-Policy: origin-when-cross-origin
< X-Content-Type-Options: nosniff
< X-Download-Options: noopen
< X-Permitted-Cross-Domain-Policies: none
< X-XSS-Protection: 1; mode=block
< X-Powered-By: Phusion Passenger 4.0.60
< Server: nginx/1.12.1 + Phusion Passenger 4.0.60
<
<?xml version="1.0" encoding="UTF-8"?>
<s3>
<urls type="array">
<url>https://<somehost>.s3.amazonaws.com/<short_name>/public/test/text4.txt?AWSAccessKeyId=<access key>&Expires=<expiration>&Signature=<signature>&x-amz-security-token=<Amazon security token></url>
</urls>
</s3>
* Connection #0 to host <short_name>.aimatch.com left intact
Step 3:
Using the find-and-replace tool in a text editor, replace any occurrences of "&" from the URL in the response with "&".
Before the find and replace:
https://<somehost>.s3.amazonaws.com/<short_name>/public/test/text4.txt?AWSAccessKeyId= <access key>&Expires=<expiration>&Signature=<signature>&x-amz-security-token=<Amazon security token>
After the find and replace:
https://<somehost>.s3.amazonaws.com/<short_name>/public/test/text4.txt?AWSAccessKeyId= <access key>&Expires=<expiration>&Signature=<signature>&x-amz-security-token=<Amazon security token>
Step 4:
Make a PUT call to upload the text4.txt file using the updated URL.
curl -v -H "Content-Type: text/plain" -X PUT " https://<somehost>.s3.amazonaws.com/<short_name>/public/test/text4.txt?AWSAccessKeyId=<access key>&Expires=<expiration>&Signature=<signature>&x-amz-security-token=<Amazon security token>" -T "/Users/username/Documents/text4.txt"
You should receive the following response, including the lines in bold below:
* Trying <IP address>...
* TCP_NODELAY set
* Connected to <somehost>.s3.amazonaws.com (<IP address>) port <port number>
* TLS 1.2 connection using <connection information>
* Server certificate: *.s3.amazonaws.com
* Server certificate: <server certificate>
* Server certificate: <server certificate>
> PUT /<short_name>/public/test/text4.txt?AWSAccessKeyId=<access key>&Expires=<expiration>&Signature=<signature>&x-amz-security-token=<Amazon security token>
> Host: <somehost>.s3.amazonaws.com
> User-Agent: curl/7.54.0
> Accept: */*
> Content-Type: text/plain
> Content-Length: 1058
> Expect: 100-continue
>
< HTTP/1.1 100 Continue
* We are completely uploaded and fine
< HTTP/1.1 200 OK
< x-amz-id-2: <amazon ID>
< x-amz-request-id: <amazon request ID>
< Date: <request date>
< x-amz-version-id: <amazon version ID>
< ETag: "504d3d1b362b8e623ad9011c0575f653"
< Content-Length: 0
< Server: AmazonS3
<
* Connection #0 to host <somehost>.s3.amazonaws.com left intact
Example 2: File Download
Step 1:
Get a list of download URLs for the files located in the test directory on S3 by using the cURL utility.
curl -v -H "Content-Type: text/plain" -X GET "https://<short_name>.aimatch.com/ads/getURLForDownloading.xml?api_key=<api key>&name=test/"
You should receive the following response:
* Trying <IP address>...
* TCP_NODELAY set
* Connected to <short_name>.aimatch.com (<IP address>) port <port number>
* TLS 1.2 connection using <connection information>
* Server certificate: *.aimatch.com
* Server certificate: <server certificate>
> GET /ads/getURLForDownloading.xml?api_key=<api key>&name=test/ HTTP/1.1
> Host: <short_name>.aimatch.com
> User-Agent: curl/7.54.0
> Accept: */*
> Content-Type: text/plain
>
< HTTP/1.1 200 OK
< Date: <request date>
< Content-Type: application/xml; charset=utf-8
< Transfer-Encoding: chunked
< Connection: keep-alive
< Status: 200 OK
< Strict-Transport-Security: max-age=631152000; includeSubdomains; preload
< Cache-Control: no-cache, no-store
< Pragma: no-cache
< Set-Cookie: _sasia_ssl_session=<session ID>; path=/; secure; HttpOnly; SameSite=<site>
< X-Request-Id: <request ID>
< X-Runtime: 0.253650
< X-Rack-Cache: miss
< Content-Security-Policy: default-src https:; base-uri 'self'; block-all-mixed-content; child-src *; connect-src https: wss:; font-src https: data:; form-action 'self' https:; frame-ancestors 'self'; img-src https:; media-src https:; object-src https:; plugin-types application/x-shockwave-flash application/pdf; script-src 'unsafe-inline' 'unsafe-eval' https:; style-src 'unsafe-inline' 'unsafe-eval' https:
< Referrer-Policy: origin-when-cross-origin
< X-Content-Type-Options: nosniff
< X-Download-Options: noopen
< X-Permitted-Cross-Domain-Policies: none
< X-XSS-Protection: 1; mode=block
< X-Powered-By: Phusion Passenger 4.0.60
< Server: nginx/1.12.1 + Phusion Passenger 4.0.60
<
<?xml version="1.0" encoding="UTF-8"?>
<s3>
<urls type="array">
<url>https://<somehost>.s3.amazonaws.com/<short_name>/public/test/text4.txt?AWSAccessKeyId=<access key>&Expires=<expiration>&Signature=<signature>&x-amz-security-token=<Amazon security token></url>
</urls>
</s3>
* Connection #0 to host <short_name>.aimatch.com left intact
Step 2:
To download the files, use the download URLs in cURL commands similar to those shown in Example 1 above.
Operating System and Release Information
| SAS System | SAS Intelligent Advertising for Publishers | N/A | | |
*
For software releases that are not yet generally available, the Fixed
Release is the software release in which the problem is planned to be
fixed.