package storageupload;
import oracle.cloud.storage.*;
import oracle.cloud.storage.model.*;
import oracle.cloud.storage.exception.*;
import java.io.*;
import java.util.*;
import java.net.*;
public class UploadingSegmentedObjects {
public static void main(String[] args) {
try {
CloudStorageConfig myConfig = new CloudStorageConfig();
myConfig.setServiceName(“Storage-usoracleXXXXX”)
.setUsername(“xxxxxxxxx@yyyyyyyyy.com”)
.setPassword(“xxxxxxxxxxxxxxxxx”.toCharArray())
.setServiceUrl(“https://storage.us2.oraclecloud.com”);
CloudStorage myConnection = CloudStorageFactory.getStorage(myConfig);
System.out.println(“\nConnected!!\n”);
if ( myConnection.listContainers().isEmpty() ){
myConnection.createContainer(“myContainer”);
}
FileInputStream fis = new FileInputStream(“C:\\temp\\hello.txt”);
myConnection.storeObject(“myContainer”, “C:\\temp\\hello.txt”, “text/plain”, fis);
fis = new FileInputStream(“C:\\temp\\hello.txt”);
myConnection.storeObject(“myContainer”, “C:\\temp\\hello1.txt”, “text/plain”, fis);
fis = new FileInputStream(“C:\\temp\\hello.txt”);
myConnection.storeObject(“myContainer”, “C:\\temp\\hello2.txt”, “text/plain”, fis);
List myList = myConnection.listObjects(“myContainer”, null);
Iterator it = myList.iterator();
while (it.hasNext()) {
System.out.println((it.next().getKey().toString()));
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
Test it and enjoy! 😉
More info
Technical: http://docs.oracle.com/cloud/latest/storagecs_common/index.html
Commercial: https://cloud.oracle.com/storage