首页 > 其他分享 >【Azure Blob】关闭Blob 匿名访问,iOS Objective-C SDK连接Storage Account报错

【Azure Blob】关闭Blob 匿名访问,iOS Objective-C SDK连接Storage Account报错

时间:2024-07-05 21:53:39浏览次数:11  
标签:account container blobs Storage Account 报错 Blob Objective Public

问题描述

iOS Objective-C 应用,连接Azure Storage Account, 根据官网Example代码,在没有关闭Storage Account的匿名访问时,程序正常运行。

但是,只要关闭了匿名访问,上传blob到Container中,就会报错:Public access is not permitted on this storage account 

 

问题解答

查看示例代码:

-(void)createContainerWithPublicAccess{
    NSError *accountCreationError;

    // Create a storage account object from a connection string.
    AZSCloudStorageAccount *account = [AZSCloudStorageAccount accountFromConnectionString:@"DefaultEndpointsProtocol=https;AccountName=your_account_name_here;AccountKey=your_account_key_here" error:&accountCreationError];

    if(accountCreationError){
        NSLog(@"Error in creating account.");
    }

    // Create a blob service client object.
    AZSCloudBlobClient *blobClient = [account getBlobClient];

    // Create a local container object.
    AZSCloudBlobContainer *blobContainer = [blobClient containerReferenceFromName:@"containerpublic"];

    // Create container in your Storage account if the container doesn't already exist
    [blobContainer createContainerIfNotExistsWithAccessType:AZSContainerPublicAccessTypeContainer requestOptions:nil operationContext:nil completionHandler:^(NSError *error, BOOL exists){
        if (error){
            NSLog(@"Error in creating container.");
        }
    }];
}

关键就是 blobContainer createContainerIfNotExistsWithAccessType:AZSContainerPublicAccessTypeContainer  这一句代码。因为示例代码中使用的是Public Access方式create container,虽然连接字符串中由Account Key,但是代码中使用的是Public Access。所以当关闭Public Access后,程序就会报错。

把 AZSContainerPublicAccessTypeContainer  修改为  AZSContainerPublicAccessTypeOff  就可以了。

 

NOTES:

  • No public read access: The container and its blobs can be accessed only with an authorized request. This option is the default for all new containers.
  • Public read access for container and its blobs: Container and blob data can be read by anonymous request, except for container permission settings and container metadata. Clients can enumerate blobs within the container by anonymous request, but cannot enumerate containers within the storage account.
  • Public read access for blobs only: Blobs within the container can be read by anonymous request, but container data is not available anonymously. Anonymous clients cannot enumerate the blobs within the container.

 

参考资料

设置Storage Account Container容器权限 : https://learn.microsoft.com/zh-cn/previous-versions/azure/storage/blobs/storage-ios-how-to-use-blob-storage#set-container-permissions

 

[END]

标签:account,container,blobs,Storage,Account,报错,Blob,Objective,Public
From: https://www.cnblogs.com/lulight/p/18286666

相关文章

  • IDEA运行时报错:Application Server was not connected before run configuration stop
    求求了,有没有大佬能看到呀,马上就考试了,运行不出来真的好烦躁无力呀,我在CSDN上看到了好多解决方法,但是我用过之后依旧没能解决。这是我的tomcat和jdk版本,版本应该没有问题吧,这也是老师发给我们的版本这是我的环境变量的配置; 这是我的tomca,jdk,以及IDEA的地址;  求......
  • 【已解决】pip已经安装好了模块,运行代码还是报错说没安装
    在Python开发中,有时用 pip 安装了模块,运行代码时却提示没安装,这让人很困惑。下面来看看可能的原因和解决办法 可能原因:1.虚拟环境出错:如果用了虚拟环境,可能装错了地方,运行代码时用的环境没装这个模块。2.Python版本不同:安装模块和运行代码的Python版本不一......
  • opencv 编译报错: error: temporary of non-literal type 'google::protobuf::intern
    完整报错:C:\Users\MyName\MyProject\lib\include\google\protobuf\stubs\mutex.h:124:error:temporaryofnon-literaltype'google::protobuf::internal::CallOnceInitializedMutex<std::mutex>'inaconstantexpressionInfileincludedfrom......
  • pyinstaller打包onnxruntime-gpu报错找不到CUDA的解决方案
    问题说明:使用onnxruntime-gpu完成了深度学习模型部署,但在打包时发生了报错:找不到CUDA具体问题描述:RuntimeError:D:\a\_work\1\s\onnxruntime\python\onnxruntime_pybind_state.cc:857onnxruntime::python::CreateExecutionProviderInstanceCUDA_PATHissetbutCUDAwas......
  • kaggle运行报错RuntimeError: cutlassF: no kernel found to launch!
    项目场景:项目场景:使用原始Llama3推理,到这里都是能行的!pipinstall-qmodelscopeimporttorchfrommodelscopeimportsnapshot_download,AutoModel,AutoTokenizerimportosmodel_dir=snapshot_download('LLM-Research/Meta-Llama-3-8B-Instruct',cache_dir='/r......
  • 解决nacos报错 Caused by: io.grpc.netty.shaded.io.netty.channel.unix.Errors$Nati
    报错信息:org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)atorg.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)atorg......
  • 海康SDK报错Structure.getFieldOrder()
    就是你调用的这个结构体以及其引用的其他结构体,可能没有getFieldOrder()的方法,你只要按照顺序把他填上去就好了。比如publicstaticclassNET_DVR_TIMEextendsStructure{//校时结构参数publicintdwYear;//年publicintdwMonth;//月......
  • opnEuler下使用xtrabackup报错libgcrypt.so.11
    环境:OS:openEuler2203sp4xtrabackup:2.4.7 [root@19copt]#/opt/xtrabackup-2.4.7/bin/innobackupex--defaults-file=/opt/mysql57/conf/my.cnf--user=root--password=mysql--socket=/tmp/mysql.sock--stream=tar/tmp|gzip>/tmp/mydb.tar.gz/opt/xtrabackup-2.......
  • git报错error: failed to push some refs to xxx
    最近在学习git的使用,发现一个本地库同步远程库的问题,先看报错截图:事情经过是,我在自己电脑里创建了一个本地库,在gitee上也创建了一个仓库,我想将我的本地库同步到gitee上的远程,但是却出现了上面的报错。下面是一些前置操作。[email protected]:id7729/git_t......
  • 7.1.SQL注入-基于函数报错的方式来利用updatexml()
    基于函数报错的方式来进行利用-字符型(本页updatexml())前提条件是后台数据库没有屏蔽数据库语法报错信息updatexml()方法详解注释:第一个参数,意思就是xml文档的名称第二个参数,意思就是定位到xml文档中指定的某一个位置的更新第三个参数,意思就是将文档中指定某一个位置......