Send attachments on mail from S3 bucket using Java - java

I want to send attachments (files from S3 bucket) in a mail triggered to users. How can be this done using Java?

I haven't tried though.
If file size greater then I would suggest to create presigned URL for files and share them via mail.
If files are too short in size, better to go with download and attach.
reference: https://docs.aws.amazon.com/AmazonS3/latest/dev/ShareObjectPreSignedURLJavaSDK.html

Related

Upload content to AWS S3 and serve the content via Cloudfront

I need to upload static contents like image to AWS S3 and provide a link back so that image can be accessed through Cloudfront CDN (content delivery network). I am new to AWS and I read that s3 bucket is linked to CDN and I believe it's all configuration based. From java code I am able to upload to s3 and get the bucket based url back. How can I retrieve CDN url from java code for the same uploaded image. Could you please help me out here.
The AWS S3 has to be manually linked to AWS CloudFront (Image attached).
Once a Distribution is created, you can see a new domain mapped to the distribution. Using that domain name you should be able to access the CDN URL in your Java code.

Amazon S3 Transfer Manager directory upload - Hashes

Currently, We implement S3 individual file uploads by adding MD5 hashes to the upload request to validate our file transfer. But now we want to leverage AWS S3 Transfer Manager for directory upload. So, now how to check for Hashes of the folders/files uploaded?
I have scouted through the documentation available on Transfer Manager but couldn't find any information on Hashes.
I believe the SDK has already taken care of that for you. The AWS Signature Version 4 calculation includes the SHA256 of the payload. [ref]

How to generate aws cloudfront url through Spring Rest api?

My requirement is that, I want to upload a file into AWS S3 bucket through Spring REST api. This api should first generate a Cloudfront url and upload the file using the url generated and finally in the response I should get the complete filepath : cloudfront-url/filename.
Please let me know the steps and configuration required to achieve this.
Thank you.
If the server uploads the file from client to s3, it will create unnecessary overhead on the server. Better approach is the return pre-signed URL to client (browser) and it directly uploads to S3.
See details on how to do it here.
If that bucket is configured for cloudfront then the cloudfront url can be used directly.
See details here for setting up cloudfront for s3.

Is it possible to get e-mail source using JavaMail?

I use JavaMail API to download mails via IMAP. I want to save them locally, in files. I have a DB, but I only want to store some meta-data in it (like mail file location).
Is there a possibility, using the JavaMail API, to get the actual source of an e-mail? Like in Outlook via context menu on a mail in a list and 'View Source'.
Thanks,
Daniel
After some more API reading I've found a solution.
javax.mail.Part#writeTo(OutputStream)
does the thing.

Newbie: query amazon s3 database in Android client (Java)

I am new in Amazon S3 service. I have an Amazon S3 database, the directory(bucket) structure is like:
-All bucket
-MyCompany
-MyProduct
-Product_1
- sub1_prod1
- sub1_prod2
...
-Product_2
- sub2_prod1
- sub2_prod2
...
As you see above, under MyProduct bucket I have several product buckets (e.g. Product_1), under each of the product bucket I have several sub-product(e.g. sub1_prod1). Each sub-product contains multiple files.
Now, I want to implement Java code in my Android client to query all my products under MyProduct bucket, how can I do this? I am using AmazonS3Client class provided by Amazon Android SDK.
P.S.:
I am able to create my AmazonS3Client object by using my credential.
AmazonS3Client s3 = new AmazonS3Client(myCred);
I know how to upload files to S3 bucket in java code, but I am not sure how to query the S3 database & get the result in my Android client, that's to get all the file names under each sub_product bucket.
I have an Amazon S3 database
IMHO, Amazon S3 is not a database, any more than a directory of files is a database. You may wish to consider other Amazon AWS services that are actual databases, such as DynamoDB or RDS.
that's to get all the file names under each sub_product bucket
By reading the documentation, it would appear that you will need to use some flavor of listObjects().
The brute-force approach would be to use the listObjects() that just takes the bucket name. That will give you a list of everything, and you would need to sort them into the tree structure yourself.
The less-brute-force approach would be to use the listObjects() that takes the bucket name and a prefix, or the listObjects() that takes a ListObjectsRequest parameter. To use filesystem terms, this will tell you the files and subdirectories in that directory. This way, you can download the pieces more easily. However, this may require a lot of HTTP requests.

Categories

Resources