简体   繁体   中英

Amazon Storage ec2 direct access like S3

I am new to Amazon, got confused about Amazon ec2, Got few queries I am unable to find on google Q: Is possible we can directly store images ( by SDK provided by amazon like S3 not by consuming rest api's ) Q: Is ec2 purely for backened services only

I have checked the android aws, they have sdk for ec2, but I am unable to figure it out, how to use to directly access ec2 instance and do some storage stuff.

SDK Link

https://github.com/aws-amplify/aws-sdk-android

The reason I am not using s3 is, S3 storage is not available in Africa Region, kind of must requirement, suggestions will be appreciated.

The s3 is available to Africa regions, Check below the comment, I have included the link which enlists all the supported regions

S3 is NOT a server and is just an Object store . Sort of like a hardware where you can store 1 file at a time. You can use S3 to save any type of files (non extendable ones). EC2 is just a server / machine which can be used for anything you like it be.

If you just want to save files on S3 using Android SDK then you can do so. Check the DownloadTask and Transfer* classes to download / upload files on S3 from Android. Reference to S3 classes in Android SDK is below

https://github.com/aws-amplify/aws-sdk-android/tree/main/aws-android-sdk-s3/src/main/java/com/amazonaws/mobileconnectors/s3/transferutility

Thanks for help, at last I found the documentation which supports all regions for amazon s3 which is https://docs.aws.amazon.com/general/latest/gr/s3.html

Rest is simple

        val amazonS3Client = getAmazonS3Client()
        var uploadObserver = TransferUtility.builder()
            .defaultBucket("enter_your_s3_bucket_name")
            .context(ApplicationCOntext)
            .s3Client(amazonS3Client).build()

        uploadObserver.upload("enter_your_s3_bucket_name",
            "" + "fileName" + ".mp4",
            File(""),
            CannedAccessControlList.PublicRead).setTransferListener(object : TransferListener {
            override fun onStateChanged(id: Int, state: TransferState?) {
                if (state == TransferState.COMPLETED) {
                    success.invoke()
                }

            }

            override fun onProgressChanged(id: Int, bytesCurrent: Long, bytesTotal: Long) {
            }

            override fun onError(id: Int, ex: Exception?) {
                exception?.invoke(ex!!)
            }
        })

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM