Last active
July 12, 2021 21:00
-
-
Save justhackit/e2e9d2c3560e6efeb4caa3f974bb2cb8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def getFileSizes(bucketName: String, prefix: String): scala.collection.immutable.Map[String, Long] = { | |
val s3 = AmazonS3ClientBuilder.standard().withRegion(Regions.US_EAST_1).build() | |
val listing = s3.listObjectsV2(bucketName, prefix) | |
val files = listing.getObjectSummaries.asScala.map(_.getKey).filter(!_.split("/").last.startsWith("_")) | |
val filesSizeMap = collection.mutable.Map[String, Long]() | |
files.foreach(obj => { | |
val meta = s3.getObjectMetadata(new GetObjectMetadataRequest(bucketName, obj)) | |
filesSizeMap += (obj -> meta.getContentLength) | |
}) | |
filesSizeMap.toMap | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment