You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jclouds.apache.org by Kenny Aondona <ru...@gmail.com> on 2014/09/28 00:48:43 UTC
Temporary URLs in TryStack
Hi,
How can I implement tempURL in Trystack. I am testing my code before a full
implementation of openstack.
Thanks.
Ken.
Re: Temporary URLs in TryStack
Posted by Andrew Phillips <an...@apache.org>.
Hi Kenny
> I want to try the temporaryURLs feature against the already created object.
> I am quite new to Java :)
Are you already trying to create a temporary URL using some code and,
if so, are you getting an exception? Or are you asking for an example
of how to create a temporary URL, assuming that is possible?
Regards
ap
Re: Temporary URLs in TryStack
Posted by Kenny Aondona <ru...@gmail.com>.
Hi,
This is the code i used to successfully create containers and objects on
TryStack.
I want to try the temporaryURLs feature against the already created object.
I am quite new to Java :)
Thanks.
private SwiftApi swiftApi;
public static void main(String[] args) throws IOException {
JCloudsSwift jcloudsSwift = new JCloudsSwift();
try {
jcloudsSwift.createContainer();
jcloudsSwift.uploadObjectFromString();
jcloudsSwift.listContainers();
jcloudsSwift.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
jcloudsSwift.close();
}
}
public JCloudsSwift() {
Iterable<Module> modules = ImmutableSet.<Module>of(
new SLF4JLoggingModule());
String provider = "openstack-swift";
String identity = "facebook123:facebook123";
String credential = "somethinglike2345";
swiftApi = ContextBuilder.newBuilder(provider)
.endpoint("http://x86.trystack.org:5000/v2.0/")
.credentials(identity, credential)
.modules(modules)
.buildApi(SwiftApi.class);
}
private void createContainer() {
System.out.println("Create Container");
ContainerApi containerApi =
swiftApi.getContainerApiForRegion("RegionOne");
CreateContainerOptions options = CreateContainerOptions.Builder
.metadata(ImmutableMap.of(
"key1", "value1",
"key2", "value2"));
containerApi.create(CONTAINER_NAME);
System.out.println(" " + CONTAINER_NAME);
}
private void uploadObjectFromString() {
System.out.println("Upload Object From String");
ObjectApi objectApi =
swiftApi.getObjectApiForRegionAndContainer("RegionOne", CONTAINER_NAME);
Payload payload = newByteSourcePayload(wrap("Hello Z Xz xZ xX
ZXWorld".getBytes()));
objectApi.put(OBJECT_NAME, payload,
PutOptions.Builder.metadata(ImmutableMap.of("key1", "value1")));
System.out.println(" " + OBJECT_NAME);
}
private void listContainers() {
System.out.println("List Containers");
ContainerApi containerApi =
swiftApi.getContainerApiForRegion("RegionOne");
Set<Container> containers = containerApi.list().toSet();
for (Container container : containers) {
System.out.println(" " + container);
}
}
public void close() throws IOException {
Closeables.close(swiftApi, true);
}
}
Regards,
Ken
On Mon, Sep 29, 2014 at 5:57 PM, Jeremy Daggett <
jeremy.daggett@rackspace.com> wrote:
> Hi Ken,
>
> Would you be able to share some code [1] with us to further assist you?
> Thx!
>
> /jd
>
> [1] http://jclouds.apache.org/reference/report-a-bug/#code
>
> From: Kenny Aondona <ru...@gmail.com>
> Reply-To: "user@jclouds.apache.org" <us...@jclouds.apache.org>
> Date: Saturday, September 27, 2014 at 3:48 PM
> To: "user@jclouds.apache.org" <us...@jclouds.apache.org>
> Subject: Temporary URLs in TryStack
>
> Hi,
>
> How can I implement tempURL in Trystack. I am testing my code before a
> full implementation of openstack.
> Thanks.
>
> Ken.
>
Re: Temporary URLs in TryStack
Posted by Jeremy Daggett <je...@RACKSPACE.COM>.
Hi Ken,
Would you be able to share some code [1] with us to further assist you? Thx!
/jd
[1] http://jclouds.apache.org/reference/report-a-bug/#code
From: Kenny Aondona <ru...@gmail.com>>
Reply-To: "user@jclouds.apache.org<ma...@jclouds.apache.org>" <us...@jclouds.apache.org>>
Date: Saturday, September 27, 2014 at 3:48 PM
To: "user@jclouds.apache.org<ma...@jclouds.apache.org>" <us...@jclouds.apache.org>>
Subject: Temporary URLs in TryStack
Hi,
How can I implement tempURL in Trystack. I am testing my code before a full implementation of openstack.
Thanks.
Ken.