我在门户上为我的特定blob生成SAS令牌,然后通过令牌成功下载它。

样本代码:

import com.microsoft.azure.storage.blob.CloudBlockBlob;

import java.io.InputStream;

import java.io.InputStreamReader;

import java.net.URI;

public class DownloadBlobSAS {

public static final String blobSasToken = "***";

public static void main(String[] args) {

try {

CloudBlockBlob sasBlob = new CloudBlockBlob(new URI(blobSasToken));

InputStream input = sasBlob.openInputStream();

InputStreamReader inr = new InputStreamReader(input, "UTF-8");

String utf8str = org.apache.commons.io.IOUtils.toString(inr);

System.out.println(utf8str);

System.out.println("print done");

} catch (Exception e) {

e.printStackTrace();

}

}

}

输出结果:

如果要生成SAS令牌,需要首先提供连接字符串以访问容器或blob。

然后你可以用

generateSharedAccessSignature()

方法来创建SAS令牌。您可以参考

sample code

:

SharedAccessBlobPolicy sp = createSharedAccessPolicy(

EnumSet.of(SharedAccessBlobPermissions.READ, SharedAccessBlobPermissions.LIST), 300);

BlobContainerPermissions perms = new BlobContainerPermissions();

perms.getSharedAccessPolicies().put("readperm", sp);

this.container.uploadPermissions(perms);

Thread.sleep(30000);

CloudBlockBlob sasBlob = new CloudBlockBlob(new URI(this.blob.getUri().toString() + "?"

+ this.blob.generateSharedAccessSignature(null, "readperm")));

希望对你有帮助。

java azure blobs sas_仅使用SAS令牌连接到Azure存储帐户?相关推荐

  1. azure 免费帐户注册_如何使用模拟器模拟Azure SQL数据库存储帐户行为

    azure 免费帐户注册 介绍 (Introduction) When you practice and play with the Azure Storage, you spent money be ...

  2. 如何使用SQL Server Management Studio(SSMS)连接到Azure存储帐户

    介绍 (Introduction) In SQL Server Management Studio (SSMS), it is possible to connect to the Azure Sto ...

  3. java azure blobs sas_使用Azure.storage.blobs在。NET Core 3.1中生成SAS过期令牌

    在这件事上有点麻烦. 在遵循Microsoft文档中的示例后,我得到了一个SAS令牌,但遇到了SAS令牌未经过身份验证的问题.string sastoken = ""; BlobS ...

  4. java azure blobs sas_使用 Java 的 Azure 存储示例 | Azure Docs

    使用 v12 Java 客户端库的 Azure 存储示例Azure Storage samples using v12 Java client libraries 11/16/2020 本文内容 下表 ...

  5. 学习Azure Functions:在Visual Studio 2017中创建Azure Functions

    目录 介绍 Azure Azure帐户设置 设置开发环境 案例分析 在Visual Studio 2017中创建Azure Functions 添加Azure Functions项目 添加HTTP触发 ...

  6. Windows Azure SDK 1.6让Visual Studio下的Azure开发更高效

    微软已发布Windows Azure SDK 1.6,其中包括适用于Visual Studio 2010的Windows Azure Tools.以及适用于.NET的Windows Azure Lib ...

  7. Azure运维系列 4:安装和使用Azure PowerShell管理云

    前面讲到了很多的管理方式,包括Azure中国最近更新的预览版管理门户和Azure云助理,都是非常不错的管理Azure的方式,今天我们再来介绍一种更加高效的管理方式Azure PowerShell.熟悉 ...

  8. azure云数据库_如何使用Cloud Shell创建Azure SQL数据库

    azure云数据库 介绍 (Introduction) Cloud Shell is a new feature just released on May 2017. It is currently ...

  9. CSDN实训 - Java模拟二次验证码(动态令牌)

    文章目录 前言 一.什么是动态令牌? 二.使用的Jar包 1. 生成二维码Jar包 2. Apache Commons Codec 3. 项目工具类 4. 下载链接 三.IDEA导入外部Jar包 四. ...

  10. java实现后端身份验证的Token令牌

    java实现后端身份验证的Token令牌 写在前面的话: 蒽,Token是一个什么东西?那我们为什么要用它? Token:Token是服务端生成的一串字符串,以作客户端进行请求的一个令牌,当第一次登录 ...

最新文章

  1. 单例模式——Singleton
  2. sed 每次只替换一行
  3. python xpath语法-Python爬虫 | 解析库Xpath的使用
  4. (原)给定输入,输出全排列
  5. RTSP学习笔记(2)live555
  6. 【天工Godwork精品教程】任务四:EOS正射影像DOM生成,DOM精编
  7. java字符串拼接_字符串拼接,什么时候会走StringBuilder?
  8. redis 管理工具_「程序猿同事的分享」redis cluster管理工具redis-trib.rb详解
  9. 大数据之-Hadoop之HDFS_基于JAVA的开发_客户端环境测试---大数据之hadoop工作笔记0055
  10. HTTP头部POST表单详解
  11. Matlab求解微分、积分方程
  12. Pyqt QThread
  13. 虚拟钢琴音源插件-GSi Genuine Sounds Vol.I Piano Edition v1.0.2 CE-win
  14. 记参加 2022 Google开发者大会
  15. 高通耳机阻抗估算流程
  16. INV TXN MANAGER PUB PROCESS TRANSACTIONS
  17. VMware安装Ubuntu-18.04.3 Server版本
  18. 解决MySQL--发生系统错误 1069。 由于登录失败而无法启动服务。
  19. SpringBoot 基本奥义
  20. BGP路由黑洞及解决方案

热门文章

  1. 不要放弃你的自由——答一些网友的评论
  2. android viewflipper 滑动事件,Android真正简单的教程-第十二枪(ViewFlipper实现滑动效果)...
  3. cmd跑绿色代码_cmd整人代码(cmd简单游戏代码)
  4. 学生信息管理系统(C语言)
  5. 字体编辑用中日韩汉字Unicode编码表
  6. c语言函数调用带参数,C语言函数 -C语言函数调用和参数传递
  7. everything的安装后初始设置
  8. 最火的C语言编程软件,适合编写C语言代码的编程软件有哪些
  9. python简单代码示例-python3简单代码示例
  10. python中如何下载安装库