Question

Purge the cache of spaces cdn with amazon sdk s3 for java version 2

Posted January 31, 2019 606 views
CDN

I’m tryind to purge cache during my build process after uploading files to spaces cdn. But can’t do it with amazon sdk java version 2.

I have this article

https://developers.digitalocean.com/documentation/changelog/api-v2/support-for-spaces-cdn-endpoints/

but can’t understand how to do it with amazon sdk. Should I user CloudFrontClient or something other?

What should I do, I wrote this code, but it fails? ( What shoud i use for distributionId?

def cfc = CloudFrontClient
.builder()
.credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials
.create(
digitalOceanProps.getProperty(“Cdnkey”),
digitalOceanProps.getProperty(“Cdn
secret”))))
.region(Region.of(“sfo2”))
.endpointOverride(URI.create(“https://sfo2.digitaloceanspaces.com”))
.build()

        def paths = Paths.builder()
                .items("/resources")
                .quantity(1)
                .build()

        def invalidationBatch = InvalidationBatch.builder()
                .paths(paths)
                .build()

        def invalidationRequest = CreateInvalidationRequest.builder()
                .distributionId("cdn")
                .invalidationBatch(invalidationBatch)
                .build()

        CreateInvalidationResponse ret = cfc.createInvalidation(
                invalidationRequest
        )
Submit an answer

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!