Amazon S3: SDK or REST API [closed]

2019-03-28 16:21发布

I have to use Amazon S3 to upload some static contents programmatically in Java. When I started reading I found that the way to do is either through their SDK (wrapper over REST APIs) or using REST APIs. From Amazon's AWS website, found this:

"You can send requests to Amazon S3 using the REST API or the AWS SDK".

Wanted to understand that which approach is better. I think using SDK will definitely make programming easier, but what are the pros and cons of using SDK Vs Rest APIs directly.

For some reason, I found using REST API directly more difficult than SDK. I was able to do basic things using SDk - create bucket, list objects, get object, invalidate cache etc. But was having some hard time writing the code for REST API - especially generating the signature.

May be it will not matter much, if I ultimately use SDK, but I would still like to know how to do it using REST APIs. If anyone has some good code examples in Java on adding objects, get objects, get list etc, it would be very helpful.

Thanks!

2条回答
放荡不羁爱自由
2楼-- · 2019-03-28 17:14

If you already have the SDK in your language, go for it; it's a no-brainer from a project perspective. The SDK is additional engineering that they have already done and tested for you at no additional cost. In other words, the SDK is already converting the HTTP REST API into the application domain/language for you.

Think of the REST API as a the lowest common denominator that AWS must support and that the SDK (likely) as implementing the REST API below it. In some cases (eg: some Windows Azure SDKs), the SDKs are actually more efficient because they switch to a TCP based communications channel instead of REST (which is TCP plus HTTP), which eliminate some of the HTTP overhead

Unless your entire goal is to spend additional time (development + testing) just to learn the underlying REST API, I'd vote SDK.

查看更多
\"骚年 ilove
3楼-- · 2019-03-28 17:26

In my own Opinion the API gives you room to do whatever you like.it also helps if you plan on changing a cloud service in the future but if the sdk approach is used, you will have to code again as your app will require a change and the SDK is embedded within your app. I know the response is late but it might help someone.

查看更多
登录 后发表回答