Skip to content
This repository was archived by the owner on Feb 4, 2019. It is now read-only.

Updated Cloud Files examples#50

Closed
jdaggett wants to merge 1 commit intojclouds:masterfrom
rackerlabs:cloudfiles-1.7.3
Closed

Updated Cloud Files examples#50
jdaggett wants to merge 1 commit intojclouds:masterfrom
rackerlabs:cloudfiles-1.7.3

Conversation

@jdaggett
Copy link
Copy Markdown

@jdaggett jdaggett commented Jun 9, 2014

This PR updates the Rackspace Cloud Files examples to use the updated 1.7.3 APIs/release.

SmokeTest was run against the examples.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What will this print, by the way? Is there something in the container we want to get and demonstrate here?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@demobox It just prints out the Container along with its information, nothing more.

@demobox
Copy link
Copy Markdown
Member

demobox commented Jun 9, 2014

Just a couple of minor comments, but am also fine with this as-is. +1 - looks good to me.

Thanks, @jdaggett!

@etoews
Copy link
Copy Markdown
Member

etoews commented Jun 9, 2014

You're going to need to update the jclouds.version in the pom.xml file for these changes to work.

@jdaggett
Copy link
Copy Markdown
Author

jdaggett commented Jun 9, 2014

@everett-toews Whoops, I had it changed in my working copy but didn't commit it. Updating now, thx!

@demobox
Copy link
Copy Markdown
Member

demobox commented Jun 9, 2014

You're going to need to update the jclouds.version in the pom.xml file for these changes to work.

Thanks, @everett-toews - good catch! Forget to check that - assumed that had already happened. Whoops...

@etoews
Copy link
Copy Markdown
Member

etoews commented Jun 9, 2014

@jdaggett UploadDirectoryToCDN doesn't work for me as is. Can you please try it to see if it works for you and verify it by trying to go to the "Go to" URL.

This is what I had to change to get it to work.

public UploadDirectoryToCDN(String username, String apiKey) {
  RegionScopedBlobStoreContext context = ContextBuilder.newBuilder(PROVIDER)
        .credentials(username, apiKey)
        .buildView(RegionScopedBlobStoreContext.class);
  blobStore = context.blobStoreInRegion(REGION);
  cloudFiles = blobStore.getContext().unwrapApi(CloudFilesApi.class);
}

and

private void uploadDirectory(String dirPath, String container) throws InterruptedException, ExecutionException {
  File dir = new File(dirPath);
  checkArgument(dir.isDirectory(), "%s is not a directory", dirPath);

  System.out.format("Uploading %s to %s", dirPath, container);

  Location location = Iterables.find(blobStore.listAssignableLocations(), new Predicate<Location>() {
     public boolean apply(Location input) {
        return REGION.equals(input.getId());
     }
  });

  blobStore.createContainerInLocation(location, container);

  List<BlobDetail> blobDetails = Lists.newArrayList();
  generateFileList(dir, "", blobDetails);
  uploadFiles(container, blobDetails);
}

Try it with those changes and see if it works for you.

@etoews
Copy link
Copy Markdown
Member

etoews commented Jun 10, 2014

@jdaggett I need this stuff right now so I'm going to merge it and make the updates.

@etoews
Copy link
Copy Markdown
Member

etoews commented Jun 10, 2014

Merged.

@etoews etoews closed this Jun 10, 2014
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can avoid the conversion to and from a String with:

Payload payload = blobStoreContext.utils().http().invoke(request).getPayload();
Files.write(payload, file);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll update that in my new (pending) PR.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in #51

etoews pushed a commit that referenced this pull request Jun 10, 2014
najtmar pushed a commit to najtmar/jclouds-examples that referenced this pull request Jul 30, 2014
najtmar pushed a commit to najtmar/jclouds-examples that referenced this pull request Jul 30, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants