0
任何人都可以幫助我舉例或示例?我需要在Blob存儲如何使用此地API連接Azure雲(blob存儲)
我設法代碼以下&放文件,
try {
CloudProvider provider = (CloudProvider) Class.forName("org.dasein.cloud.azure.Azure").newInstance();
ProviderContext providerContext = new ProviderContext("DEV","West US");
//providerContext.setStorage("");
providerContext.setStorageAccountNumber("mypackages");
providerContext.setStoragePublic("XXX".getBytes());
providerContext.setEndpoint("http://XXX.blob.core.windows.net/");
providerContext.setStorageX509Key("YYY".getBytes());
provider.connect(providerContext, provider);
System.out.println("here "+provider.testContext());
} catch (InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
在上面的代碼我得到NPE如下
org.dasein.cloud.InternalException: java.lang.NullPointerException
at org.dasein.cloud.azure.AzureX509.<init>(AzureX509.java:64)
at org.dasein.cloud.azure.AzureMethod.getClient(AzureMethod.java:386)
at org.dasein.cloud.azure.AzureMethod.getAsStream(AzureMethod.java:124)
at org.dasein.cloud.azure.Azure.testContext(Azure.java:258)
at com.gehcit.dasein.App.main(App.java:27)
Caused by: java.lang.NullPointerException
at java.lang.String.<init>(Unknown Source)
at org.dasein.cloud.azure.AzureX509.<init>(AzureX509.java:58)
... 4 more
org.dasein.cloud.InternalException: java.lang.NullPointerException
at org.dasein.cloud.azure.AzureX509.<init>(AzureX509.java:64)
at org.dasein.cloud.azure.AzureMethod.getClient(AzureMethod.java:386)
at org.dasein.cloud.azure.AzureMethod.getAsStream(AzureMethod.java:124)
at org.dasein.cloud.azure.Azure.testContext(Azure.java:258)
at com.gehcit.dasein.App.main(App.java:27)
Caused by: java.lang.NullPointerException
at java.lang.String.<init>(Unknown Source)
at org.dasein.cloud.azure.AzureX509.<init>(AzureX509.java:58)
... 4 more