© 2014 IBM Corporation
Using Java to access
Object Storage v2 in Bluemix
Joseph Chang
Senior IT Specialist
IBM Cloud Group
Document number
© 2014 IBM Corporation
 https://github.com/whitfiea/bluemix-objectstorage-v2
2
The sample code in this slide is from the
following url.
© 2014 IBM Corporation
Take me to Bluemix
Click Here
If you need the guidance and sample code of using
Java to access object storage v2 in bluemix, go
ahead.
© 2014 IBM Corporation4
https://ibm.biz/BdEzTZ
Read/Write files with OpenStack Dashboard
You can use openstack
dashboard to read/write
container/folder/file
in object storage v2.
© 2014 IBM Corporation5
Click Here.
© 2014 IBM Corporation6
Click Here.
© 2014 IBM Corporation7
Fill in user
name and
password.
Then click sign
in.
© 2014 IBM Corporation8
Click
Object Store ->
Container
© 2014 IBM Corporation
Now you see the containers, folders, files.
9
You can create folder/ upload
files with this dashboard
© 2014 IBM Corporation
Now let’s create object storage service from catalog.
10
Your service
created.
© 2014 IBM Corporation
Click the service, you can see the number of containers and objects.
11
© 2014 IBM Corporation
Click Show Credentials.
12
Take note for all of these
information. We will use these
info in our Java code.
© 2014 IBM Corporation
Now let’s look at the Java code. You can view it from JazzHub.
 https://hub.jazz.net/code/edit/edit.html#/code/file/joseph-OrionContent/joseph
%2520%257C%2520jx-object-storage2/
13
© 2014 IBM Corporation
Or you can take a copy to local.
14
git clone https://hub.jazz.net/git/joseph/jx-object-
storage2/
© 2014 IBM Corporation
Use Eclipse to import the sample code
15
© 2014 IBM Corporation
Libraries required by this sample
16
© 2014 IBM Corporation
Sample 1 : Java Application in Local
17
© 2014 IBM Corporation
Classes required by this sample
18
© 2014 IBM Corporation
You can get the information from object storage service credential.
Refer to p.12.
19
© 2014 IBM Corporation
Connect to Object Storage with SwiftApi
20
© 2014 IBM Corporation
Java main program
21
© 2014 IBM Corporation
Using ContainerApi and ObjectApi
22
© 2014 IBM Corporation
Using ContainerApi and ObjectApi
23
© 2014 IBM Corporation
Let’s run it
24
© 2014 IBM Corporation
View the log in eclipse console
25
© 2014 IBM Corporation
Sample 2 : Java Servlet in Bluemix Liberty
26
© 2014 IBM Corporation
Prepare the manifest file
27
Replace the
host name,
object storage
service name
with yours.
© 2014 IBM Corporation
View the Servlet souce
28
The servlet which
running in Bluemix liberty
with automatically take
the environment
variables.
© 2014 IBM Corporation
Deploy it with cf push
29
© 2014 IBM Corporation
The application is running
30
© 2014 IBM Corporation
View the result in Browser
31
© 2014 IBM Corporation
Thank you
32
Take me to Bluemix
Click Here

Using java to access bluemix object storage v2

  • 1.
    © 2014 IBMCorporation Using Java to access Object Storage v2 in Bluemix Joseph Chang Senior IT Specialist IBM Cloud Group Document number
  • 2.
    © 2014 IBMCorporation  https://github.com/whitfiea/bluemix-objectstorage-v2 2 The sample code in this slide is from the following url.
  • 3.
    © 2014 IBMCorporation Take me to Bluemix Click Here If you need the guidance and sample code of using Java to access object storage v2 in bluemix, go ahead.
  • 4.
    © 2014 IBMCorporation4 https://ibm.biz/BdEzTZ Read/Write files with OpenStack Dashboard You can use openstack dashboard to read/write container/folder/file in object storage v2.
  • 5.
    © 2014 IBMCorporation5 Click Here.
  • 6.
    © 2014 IBMCorporation6 Click Here.
  • 7.
    © 2014 IBMCorporation7 Fill in user name and password. Then click sign in.
  • 8.
    © 2014 IBMCorporation8 Click Object Store -> Container
  • 9.
    © 2014 IBMCorporation Now you see the containers, folders, files. 9 You can create folder/ upload files with this dashboard
  • 10.
    © 2014 IBMCorporation Now let’s create object storage service from catalog. 10 Your service created.
  • 11.
    © 2014 IBMCorporation Click the service, you can see the number of containers and objects. 11
  • 12.
    © 2014 IBMCorporation Click Show Credentials. 12 Take note for all of these information. We will use these info in our Java code.
  • 13.
    © 2014 IBMCorporation Now let’s look at the Java code. You can view it from JazzHub.  https://hub.jazz.net/code/edit/edit.html#/code/file/joseph-OrionContent/joseph %2520%257C%2520jx-object-storage2/ 13
  • 14.
    © 2014 IBMCorporation Or you can take a copy to local. 14 git clone https://hub.jazz.net/git/joseph/jx-object- storage2/
  • 15.
    © 2014 IBMCorporation Use Eclipse to import the sample code 15
  • 16.
    © 2014 IBMCorporation Libraries required by this sample 16
  • 17.
    © 2014 IBMCorporation Sample 1 : Java Application in Local 17
  • 18.
    © 2014 IBMCorporation Classes required by this sample 18
  • 19.
    © 2014 IBMCorporation You can get the information from object storage service credential. Refer to p.12. 19
  • 20.
    © 2014 IBMCorporation Connect to Object Storage with SwiftApi 20
  • 21.
    © 2014 IBMCorporation Java main program 21
  • 22.
    © 2014 IBMCorporation Using ContainerApi and ObjectApi 22
  • 23.
    © 2014 IBMCorporation Using ContainerApi and ObjectApi 23
  • 24.
    © 2014 IBMCorporation Let’s run it 24
  • 25.
    © 2014 IBMCorporation View the log in eclipse console 25
  • 26.
    © 2014 IBMCorporation Sample 2 : Java Servlet in Bluemix Liberty 26
  • 27.
    © 2014 IBMCorporation Prepare the manifest file 27 Replace the host name, object storage service name with yours.
  • 28.
    © 2014 IBMCorporation View the Servlet souce 28 The servlet which running in Bluemix liberty with automatically take the environment variables.
  • 29.
    © 2014 IBMCorporation Deploy it with cf push 29
  • 30.
    © 2014 IBMCorporation The application is running 30
  • 31.
    © 2014 IBMCorporation View the result in Browser 31
  • 32.
    © 2014 IBMCorporation Thank you 32 Take me to Bluemix Click Here