我已经尝试了链接,这个,但它仍然不工作我不知道为什么 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