Upload images added to gallery to aws s3 folder automatically from background - java

I have an android application which have integrated with aws cognito(user and identity pools) and aws s3.Sign up and sign in features are working fine and after signing in user can view the images in s3 bucket related to his/her folder in s3 bucket. When user is signing in a directory in s3 bucket is created.Currently images should be uploaded to the relevant folder manually through the aws s3 console.
Now what I want to do is, when new images are added to the gallery(through camera or downloaded from somewhere) it should be uploaded to the user's relevant folder automatically even when the app is closed(similar like google photos app).
I don't know is there a method in android to get notified when new image(s) added to the gallery and get that image.(I don't want to delete the image in the s3 when an image is deleted in gallery)
And if notified can it be uploaded to the s3 bucket from background since in a token expiry situation user have to sign in again(as I know)?
What I want to know is, is this task possible to do?
If possible what is the preferred solution and basic steps I should follow to solve my problem?

Related

Ways to show protected image on UI

I am curious to know, how to show any image or document which is stored on a private S3 bucket and I need to show it on UI to some authorized users. Just like facebook and instagram do it, to secure their images. I can not put images on a public bucket otherwise anyone can view and download it and it won't be secure. I was thinking about some solutions but every solution has it's own pros and cons. I think about below solutions:
Solution 1:
I can put all the images in a private S3 bucket and an auth token can be associated with image url as a query param. This image url would be passed to image server and image server will validate the auth token. If it is a valid one then, image would be fetched from private S3 bucket to image server and downloaded to client in byte array.
This approach has multiple disadvantages like:
Image has to travel from S3 bucket to image server and again image server to client device. It will add more latency and this would be increased with size of image.
This approach is not scalable. If I think that 100 image read requests are coming in a second and every image has a size of 5MB, then approx 500MB content would present in the memory every time. And with the time when traffic would be on it's peak, server goes down.
I can think to cache images for faster response but image caching will take a lot of space and for the request of every server above problems would occur.
Solution 2
We can think to bypass image server and try to download image from the S3 bucket directly to the client device. If user is logged in, then client can download images using secret key of private bucket. Again this approach has some advantages:
we have to configure secret key of private bucket in client devices like Android, IOS, web, etc. There are high chances to leak secret key from the frontend resources.
In future if I think to replicate image content for faster service in different geographical locations, then it is hard to maintain different secret key for each bucket.
Apart from that other solution which can serve our purpose?
Solution 1 is good, but you don't need a server... Amazon S3 can do it for you.
When your application wants to provide a link to a private object, it can generate an Amazon S3 pre-signed URLs, which is a time-limited URL that provides access to a private object. It can be included in your HTML page (eg <img src="...">) or even as a direct URL.
The beauty of this approach is that your app can generate a pre-signed URL in a few lines of code (no call to AWS required) and then Amazon S3 will do all the serving for you. This means there is less load on your application server and it is highly scalable.

is upload image to firebase storage needs permission?how?

I am about to publish my new android java app,
I upload image profile to firebase storage,
Its working,
Without any permissions requests,
I am afraid that my app may not be accepted in app store because of no asking for permission,
So the question is:
is upload image to firebase storage needs permission and how?
If you performed a normal integration of the Cloud Storage SDK for Firebase, then you don't need to do anything special. Your app will have all the required permissions by default.
After added os version M. You need ask Run time permission for access storage.

Upload file From AWS s3 bucket

I need help with getting file from AWS S3 bucket.What I want is when I click file browse to browse the file,till now I was uploading file through my local disk.But now what I want is when I click browse,it should show me to upload file from s3 bucket.I want this functionality to validate my files on s3 bucket according to some validations.Through local files,It's much easier but now need solution over uploading from AWS S3.How can I accomplish this?I am stuck.
Any help would be very much appreciable.
If you are doing this from the console, and the other S3 bucket (that you want to upload from) is in your account, you can simply copy from that bucket and paste it in this bucket of yours.

Store files in google drive from Google App Engine

All,
I have a google application engine (java) that requires to store some images. I tried using Blobs and storing them in datastore but as you know there is a size limit on data that can be stored in datastore.
So as result I'm storing the images on a different server and store the path in my datastore and all works fine.
Now I'm thinking on using a google drive folder instead of using a server to upload the files to the drive and using the share link to display them later.
I've seen https://developers.google.com/drive/web/quickstart/java and got it to work fine. When I try to use it in my application however obviously this won't work as the code is assuming a credential for a local user.
I created a service key on my application and want to change the sample code above to use it but I'm not sure if that's the correct approach.
Tried searching for samples but can't find anyone that takes the same approach. Is there a working sample that shows how to authenticate an application not a user and let's say store a file in google drive?
I've also seen https://developers.google.com/drive/web/examples/ please note what I want is to store files in my google drive and not the user's google drive. So if user A and user B come to my app, they shouldn't have to authorize my application and should both be able to upload a file to my google drive.
I don't know if this can be done directly from their browser or I have to move the file to my application (appspot) and then push it to google drive.
Thanks

Share a Photo On a Web-Service And Get The Public URL?

I want to build an app in which the user chooses a gallery photo.
It then
uses "share via" to upload the photo from my device to any other 3rd party application that hosts files on the server.
then it saves the hoting url. Adds it to a UI list.
Are there any apps that retrieve the posting public url after the post is done - so I can use it in my app ?

Categories