我已經嘗試了鏈接,這個,但它仍然不工作我不知道爲什麼 CloudStorageAccount帳戶=新CloudStorageAccount(ST,真); CloudBlobClient blobClient = account.createCloudBlobClient(); CloudBlobContainer container = blobClient.getContainerReference(uid); container.createIfNotExists(); BlobContainerPermissions containerPermissions = new BlobContainerPermissions(); containerPermissions.setPublicAccess(BlobContainerPublicAccessType.CONTAINER); container.uploadPermissions(containerPermissions); 文件fl = new File(fileUri.getPath());錯誤連接到Blob存儲
CloudBlockBlob blob1 =container.getBlockBlobReference(fl.getName());
blob1.upload(new FileInputStream(fl), fl.length());
雖然試圖上傳到Blob存儲的圖像我不斷收到無法連接到****。blob.core.windows.net
try {
//Get the rocket data
FileInputStream fis = new FileInputStream(mFilePath);
int bytesRead = 0;
ByteArrayOutputStream bos = new ByteArrayOutputStream();
byte[] b = new byte[1024];
while ((bytesRead = fis.read(b)) != -1) {
bos.write(b, 0, bytesRead);
}
byte[] bytes = bos.toByteArray();
fis.close();
// Post our rocket data (byte array) to the server
URL url = new URL(mBlobUrl.replace("\"", ""));
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setDoOutput(true);
urlConnection.setRequestMethod("PUT");
urlConnection.addRequestProperty("Content-Type", "image/jpeg");
// Write image data to server
DataOutputStream wr = new DataOutputStream(urlConnection.getOutputStream());
wr.write(bytes);
wr.flush();``
wr.close();
int response = urlConnection.getResponseCode();
//If we successfully uploaded, return true
if (response == 201
&& urlConnection.getResponseMessage().equals("Created")) {
return true;
}
} catch (Exception ex) {
Log.e(TAG, ex.getMessage());
}
(@只是格式化代碼正確顯示)
TNX @Guarav但我得到了我寫的代碼參照樣本項目上thier網站 – coderwithattitude 2014-09-02 08:25:05
你能分享鏈接? – 2014-09-02 10:47:39
我ü回答它沒有工作嘗試在這裏是鏈接http://azure.microsoft.com/en-us/downloads/ – coderwithattitude 2014-09-03 10:38:52