AWS S3 Java SDK provides a method doesObjectExist()
to check if an object exists in S3. What operation does it use internally? Is it GET
, LIST
, or HEAD
?
My concern is mainly related to its costs. From S3 documentation the costs of US west Oregon are- PUT, COPY, POST, or LIST Requests $0.005 per 1,000 requests
GET, SELECT and all other Requests $0.0004 per 1,000 requests
Does the cost of doesObjectExist()
fall under 1st or 2nd category? Also I was reading somewhere that this operation requires ListBucket
and GetObject
permissions. So does that mean this operation incurs cost of both the above categories?
Any data stored in this storage class has a pricing per terabyte of only $4.10 USD per month.
S3 Intelligent-Tiering pricing You pay for monthly storage, request and data transfer. When using Intelligent-Tiering you pay a small monthly per-object fee ($0.0025 per 1000 objects) for monitoring and automation. There is no retrieval fee in S3 Intelligent-Tiering and no fee for moving data between tiers.
Standard data transfers from the Internet to AWS S3 buckets are free, but data transfers outside AWS S3 incur costs. Amazon uses a tiered data transfer pricing structure, with a lower cost the more data you transfer outside the S3 service each month.
Looking at the code, the doesObjectExist()
method internally calls getObjectMetadata
(link, link).
If you go a little deeper into the code, the actual HTTP request is a HEAD
request, so I strongly suspect they are just doing a HEAD
on the object itself.
The description of GetObjectMetadataRequest
and the HEAD
call on the REST API are also similar.
Regarding permissions, you are correct (the excerpt below also comes from the HEAD
request on the REST API:
You need the s3:GetObject permission for this operation. For more information, go to Specifying Permissions in a Policy in the Amazon Simple Storage Service Developer Guide. If the object you request does not exist, the error Amazon S3 returns depends on whether you also have the s3:ListBucket permission.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With