Report this

What is the reason for this report?

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

Posted on January 31, 2019

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(“Cdn_key”), 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
        )


This textbox defaults to using Markdown to format your answer.

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

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.