presigned url for aws s3 in akka java application - akka

I am using Akka framework and writing a Java application that talks to AWS S3. Is there any example of generating a pre-signed get request for s3 in java using Akka framework? Alpakka S3Client does not have any method in its interface to create a pre-signed request.

Related

Differentiate between website endpoint from REST API endpoint for AWS S3

I have an input provided by a user, that would be used as the endpoint url for bucket operations for an S3 bucket.
Is there a way to differentiate if the url is a REST API endpoint or a website endpoint?
I did read: https://docs.aws.amazon.com/AmazonS3/latest/userguide/WebsiteEndpoints.html
which mentions "Supports only GET and HEAD requests on objects" for a website endpoint.
However, i have come across cases where the other operations worked even with a website endpoint.
I am using python boto3 for these APIs.
With only S3 you can't upload any data. It's a static website hosting, without any logic or ability to process data. You're just storing files that browser renders.
If you need logic I'd suggest adding some Lambda functions with REST endpoint. For your needs, you'll probably stay in free tier.

How Do I Access S3 Bucket Files in Browser Using AccessKeyId and SecretAccessKey?

I have accessKeyId and secretAccessKey for AWS S3 bucket. How do I access the video files on the bucket using the browser?
I'm using React and Node(Nest.js). I would like to play the video files on the React Frontend
If your web page has AWS credentials, then you can use the AWS JavaScript SDK in the browser to create a pre-signed URL for the video file in S3, then provide that URL to your video player.
If the web page doesn't have AWS credentials and can't easily get them, then consider using AWS Amplify or write a small server-side component to do this on behalf of your client.
Note that pre-signed URLs have an associated expiration date/time.

Get AWS Lambda url from cdk and insert it into a frontend application

I have an aws cdk stack i am writing in typescript. It consists of a react app stored in an s3 bucket (via s3 bucket deployment). I also have an api gateway running a websocket api. I now need to join the two together, by telling the react app the url of the api gateway, ideally via the deploy step.
I have tried writing the token to a file before deploying, but the string is still tokenised, so i end up with wss://${Token[TOKEN.243]}..., so the write is too early. I have tried writing the file via cdk deploy -O but at that point its too late to ship it with the deploy.
How can I inform my react application of the web api url?
When I do this pattern, I will use CloudFront to proxy /api/* to my API Gateway and everything else to the S3 bucket website url. Then the react code just has to make requests on /api
You can divide your Stack in 2 parts.
Api Stack
ReactApp stack
Deploy Api Stack first with -O options to write api url into some json file in directory getting deployed to s3.
Now you have json having api url in json file and you can deploy ReactApp Stack now.
Note: In your react app you can should read the url from the file that will be generated by cdk deploy -O <filename>.json.

Is there any way to to send large file through API Gateway?

I'm working on the application that will receive files from users and then upload to Amazon S3. The application is accessed using API Gateway. The service API Gateway has limits for payload size for both WebSocket and REST APIs. Is there any way to access my service from the Internet through API Gateway?
API gateway is not intended to be data transfer gateway, but lightweight API definition layer.
The most suitable approach is to generate temporary pre-signed upload URL and redirect (30X) requests there. API Gateway should define an endpoint, calling lambda function which generates pre-signed S3 URL and redirect post request there (after user's authentication of course).
Please refer an example of app with API Gateway and pre-signed S3 URLs to upload files
API documentation for generating pre-signed S3 URLs in Python, AWS CLI and even Go-lang

Upload file to s3 with custom response to client

I am trying to upload a file to s3 and then have lambda generate id, date.
I then want to return this data back to the client.
I want to avoid generating id and date on the client for security reasons.
Currently, I am trying to use API Gateway which invokes a lambda to upload into s3. However, I am having problems setting this up. I know that this is not a preferred method.
Is there another way to do this without writing my own web server. (I would like to use lambda).
If not, how can I configure my API Gateway method to support file upload to lambda?
You have a couple of options here:
Use API Gateway as an AWS Service Proxy to S3
Use API Gateway to invoke a Lambda function, which uses the AWS SDK to upload to S3
In either case, you will need to base64 encode the file content before calling API Gateway, and POST it in the request body.
We don't currently have any documentation on this exact use case but I would refer you to the S3 API and AWS SDK docs for more information. If you have any specific questions we'd be glad to help.
Thanks,
Ryan