Appery.io aws S3 integration - amazon-web-services

Looking for help on how to have a appery.io ionic 5 app upload images, files, videos etc. to aws S3. I am using aws DynamoDB thru API Express successfully and can get a presigned S3 URL thru API Express as well. My problem is using the presigned URL to upload a image/file. Tried fetch, httpClient etc. Some Guidence would be greatly appreciated.
Thank you

To work with binary data in API Express you can do the following:
Create new service of Custom REST API type
In START node select POST method and Binary for request body
With that you should be able to select Binary request as parameter value in SQL node
The second part of the question is how can you get the binary data if you have fileUrl.
Import API Express service created on a previous step into your project with Create New > API Express service
On Code tab create a variable named buffer of type Any
On Data tab add datasource for the imported API Express service. In Before send mapping connect buffer with body.data
Drop the button on Screen1
Add event with TypeScript code to it:
fetch(fileUrl).then(res => res.arrayBuffer()).then(arrayBuffer => {
this.buffer = arrayBuffer;
this.Apperyio.execDataService(this, "myAexService");
});

Related

How to solve the OPTIONS 500 error in AWS API Gateway?

I have created a React Application to upload a file to the S3 bucket. To do this, I have created a PUT API from the AWS API Gateway and the API is working well in the POSTMAN. The problem is, when I call the API from my React Application locally (http://localhost:3000), I'm getting a 500 error from the OPTIONS request (Preflight).
I have set the Binary Media Types to "image/jpeg" and When I remove the Binary Media Types, the API returns the 200 response, but then, an empty image is uploaded without its content.
How can I solve this?
This is my Request Integrations of both the PUT method and the OPTIONS method
PUT
OPTIONS
Binary Media Types

How to access CloudFront Cache Statistics via SDK

I am trying to access the Cloudfront Cache Statistics programmatically. Via the UI you can see the Statistics via clicking on "CloudFront" and then on the left side under "Reports & analytics" the link "Cache Statistics".
I am using the Java SDK 1.11. However the structure is similar in all sdk bindings. I already tried:
AmazonCloudFront cloudFront = AmazonCloudFrontClientBuilder.defaultClient();
GetDistributionRequest request = new GetDistributionRequest();
request.setId("E3C1N6KKRS04QE");
GetDistributionResult result = cloudFront.getDistribution(request);
System.out.println(result);
However, that seems to get my the information shown on the "Distribution"-Tab in the UI. Any help would be appreciated!

AWS API Gateway Integration Request setup automation

I am trying to use the AWS API Gateway+Swagger to route the request to my express backend. I can't figure out how to automate the setup of the integration request as the Swagger file has no details on it.
I'm also having difficulty with the endpoint url parameter when setting my method requests to GET/VPC Link on the integration type
For example:
My api gateway path is /info/car/{model}/aggregate
Now the endpoint url is http://carapi.com/info/car/{model}/aggregate
I have lots of gateway paths all of which are the same paths that my carapi.com site uses, so I don't want to keep retyping the path over and over. When entering in the endpoint url, I was able to simplify not having to type carapi.com by using stage variables turning my endpoint url to
http://${stageVariables.carApi}/info/car/{model}/aggregate
However after reading https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html#stagevariables-template-reference
I see that there is also a $context available, but it gives me an error(when I try to call the api in postman, says 'internal server error' for the message) when I try to implement the context (which through that link shows that I can implement the path).
http://${stageVariables.carApi}/${context.resourcePath}
So my question is: how do I automate the setup of Integration requests so I don't have to manually setup each and every one(as I have hundreds of paths)? Is there also anyway to not have to set the paths manually for the endpoints?
I don't know of any solution which is ready to use.
In my project, we wrote a custom solution that downloads the application Swagger json, parses it, adds the required integration and generates another json file. Then we import that into API Gateway. This has been converted as a Jenkins job and runs as a post job of microservice deployment.
Another way is, instead of generating the json, directly call API Gateway APIs and add the integration.

Power BI Web Source Wont Update through Gateway

I have an API source I am using on a report. It works fine on my Desktop, and I added the URL and Basic Login credentials to my Gateway. I get an error that my source is unable to update, but I don't know why. When I test the connection in my Gateway it says it connects fine. For some reason my published data set doesn't recognize the report's source as the same one as the one in my gateway.
Is there any additional step required in publishing a Web Data Source in order to make it use the gateway's web source?
This is the Error I get:
This is the Gateway's connection to the API:
This is the (Much Truncated) version of the Query I am using to retrieve the data:
let
Url = "https://rest.avatax.com/api/v2/companies/XXXX/transactions/",
RawData = Web.Contents(Url),
Json = Json.Document(RawData)
in
Json
This an incredibly annoying "feature", but the Power BI service does a different code analysis than Power BI Desktop. The way to overcome it is to present a static URL like this:
let
Source = Json.Document(Web.Contents("https://rest.avatax.com/api/v2/companies/XXXX/transactions/"))
in
Source
Chris Webb described this in more detail (along with hacks to make the URL dynamic) in this blog post:
https://blog.crossjoin.co.uk/2016/08/23/web-contents-m-functions-and-dataset-refresh-errors-in-power-bi/

Handle Space in AWS API Gateway API URL - I am using Dynamodb Proxy

I have a AWS API Gateway - and using dynamodb to read Data from database, its running good enough if I sent a parameter without Space.
URL Pattern: API_LINK/benchmark_performance/{benchmark}
if {benchmark} is replaced with a String with a space - AWS replies with no/blank data, No Error Reported. if the parameter doesn't have space in it then it sends data correctly. I also tried using JS URI_encoder method and send it but same result
If I test the AWS API End point from AWS console (parameter has Space), then the result is shown properly but the same URL gives no data when called from Browser or angular 2 Application.
Question: What should I do at AWS API Gateway Integration Mapping, that it gives me proper output and handles the space in parameter issue.
Got the answer : http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html
I used :
$util.urlDecode() (Decodes an "application/x-www-form-urlencoded" string).
how to use =>
$util.urlDecode($.input.params('yourParameterName'))
in Integration Mapping (section) of API Gateway