ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、视频、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
[TOC] [文档](https://help.aliyun.com/zh/oss/developer-reference/?spm=a2c4g.11186623.0.0.78a725f5fh6Ojs)  [登录地址](https://account.aliyun.com/login/login.htm?oauth_callback=https://oss.console.aliyun.com/index) ## 1、可选[创建资源组](https://resourcemanager.console.aliyun.com/resource-groups) ![](https://img.kancloud.cn/90/48/90484a20949bf2bd63db492dd64a5506_1332x627.png) ![](https://img.kancloud.cn/b7/74/b774ed320695699b2fb5a0063b745092_1307x568.png) ## 2、[创建Bucket](https://oss.console.aliyun.com/bucket) ![](https://img.kancloud.cn/47/46/47466ef88bb025caefc04ff87195132e_1348x654.png)  ### **读写权限:** (1)私有:对object的所有访问操作需要进行身份验证。就是普通用户或其他用户没有经过认证,它是访问不了的。  (2)公共读:对object写操作()需要进行身份验证:可以对object进行匿名读。就是其他人可以没有经过认证就去读,访问bucket资源,没有写的权限。  (3)公共读写:所有人都可以对object进行读写操作。  选择私有权限,点击提交,在列表里就可以看见创建完的bucket。  新建bucketName(需要全局唯一)。   ### **存储冗余类型 [说明](https://aliyun.cloudduo.cn/oss_zrs_lrs.html)** * 同城冗余ZRS(0.15元/GB/月):将您的数据冗余存储在同**一个区域的多个可用区**,可支持单个可用区(机房)整体故障时(如断电、火灾等),仍维持数据不丢失,可正常访问。 * 本地冗余LRS(0.12元/GB/月):将您的数据冗余存储在同**一个可用区的不同存储设备上**,可支持两个存储设备并发损坏时,仍维持数据不丢失,可正常访问。  ### **读写权限** public-read-write,public-read和private  常见问题小结 (1)bucket设置为私有,能否防止恶意下载 不能防止,一但对应资源的签名url对外暴露,在签名url有效期内就可以通过签名url下载对应的资源。  (2)bucket私有,获取到的资源链接是否具有时效性 有时效性,一但过期就不可被访问。  (3)获取到的资源链接是否可以永久有效 将bucket改为公共读/公共读写,获取到的object链接一般都是永久有效的,但是如果bucket私有则一般获取的链接是有时效的。  ## **控制台上传** 1、新建文件夹(区分大小写) ![](https://img.kancloud.cn/59/4a/594aa1d9f4ece462ccea503c81a55d33_693x185.png) 2、找test目录点击上传文件比如我么上传选择B文件夹那么他会将B文件和里面的子文件等都上传上去(一次最多10000文件并且最大不来了个超过5G) ## **准备** 1、创建用户: 身份管理-创建用户:此步骤需要手机验证 ![](https://img.kancloud.cn/35/46/35465564b3437dac1390455c7aa1d6cf_1162x408.png) 保存好AccessKeyID和AccessKey secret (secret_key,这个只显示一次,后续不会在出现) ![](https://img.kancloud.cn/4c/1f/4c1f37b34dd968fc0c5c134b34a71f6d_1177x302.png) 授予该用户 AliyunOSSFullAccess系统策略管理对象存储服务(OSS)权限 ![](https://img.kancloud.cn/46/27/4627a6fcdc9ef9947a136d1f3f280e1e_1311x507.png) 2、拿到该用户的信息 * AccessKeyID * AccessKey secret * endpoint:oss-cn-beijing.aliyuncs.com [访问域名和数据中心](https://help.aliyun.com/zh/oss/user-guide/regions-and-endpoints#concept-zt4-cvy-5db)获取(注意前面加上http://或者htps://,想要那个协议加上对应的) ![](https://img.kancloud.cn/d7/5d/d75d6f2c0a3c39e915dc6bc5a39eb467_903x104.png)   根据提示分别设置Endpoint、AccessKey ID、AccessKey Secret和STSToken参数。 | **参数**| **说明**| | --- | --- | | endpoint| 填写Bucket所在地域的Endpoint。关于各地域Endpoint的更多信息,请参见[访问域名和数据中心](https://help.aliyun.com/zh/oss/user-guide/regions-and-endpoints#concept-zt4-cvy-5db)。<br>您也可以增加`http://`或`https://`指定ossutil访问OSS使用的协议,默认使用HTTP协议。例如,使用HTTPS协议访问华东1(杭州)的Bucket,设置为`https://oss-cn-hangzhou.aliyuncs.com`。| | accessKeyID| 填写账号的AccessKey。<br>* 使用阿里云账号或RAM用户访问时,AccessKey的获取方式,请参见[创建AccessKey](https://help.aliyun.com/document_detail/53045.html#task968)。<br>* 使用STS临时授权账号访问时,AccessKey的获取方式,请参见[使用STS临时访问凭证访问OSS](https://help.aliyun.com/zh/oss/developer-reference/use-temporary-access-credentials-provided-by-sts-to-access-oss#concept-xzh-nzk-2gb)。| | accessKeySecret| | stsToken|使用STS临时授权账号访问OSS时需要配置该项,否则置空即可。关于stsToken的生成方式,请参见[临时访问凭证](https://help.aliyun.com/zh/oss/user-guide/authorized-third-party-upload#section-dvv-hkb-5db)。 | **说明** 关于配置文件的更多信息,请参见[config](https://help.aliyun.com/zh/oss/developer-reference/config#concept-303826)。      [对象存储OSS](https://help.aliyun.com/zh/oss/developer-reference/common-tools/?spm=a2c4g.11186623.0.0.61c528c43Xxa5Z)>[开发参考](https://help.aliyun.com/zh/oss/developer-reference/?spm=a2c4g.11186623.0.0.710e94e0a4iI01)>[常用工具](https://help.aliyun.com/zh/oss/developer-reference/common-tools/?spm=a2c4g.11186623.0.0.57bd2435fkRmBl)>[# 命令行工具ossutil](https://help.aliyun.com/zh/oss/developer-reference/ossutil-1/?spm=a2c4g.11186623.0.0.29d32ef5LcfHd3)     ## **下载**[**ossutil**](https:help.aliyun.com/zh/oss/developer-reference/install-ossutil?spm=a2c4g.207217.0.i0#concept-303829)**Tools** 运行ossutil.bat Extract the tool and double-click to run the ossutil.bat file ### **配置** ![](https://img.kancloud.cn/d1/55/d1558acee8441fa044df3e0ddfd019df_841x304.png) ![](https://img.kancloud.cn/0a/21/0a21235ff27d171a6b53b033ff5b2401_404x150.png) ### **验证是否已成功安装ossutil。** Enter ossutil to verify success, a black window displays many commands and explains success ``` Commands: mb cloud_url [options] Create a bucket ls [cloud_url] [options] List buckets or objects rm cloud_url [options] Delete buckets or objects stat cloud_url [options] Displays the description of the bucket or object set-acl cloud_url [acl] [options] Set ACLs for buckets or objects set-meta cloud_url [meta] [options] Set the meta information of the uploaded objects cp src_url dest_url [options] Upload, download or copy Objects restore cloud_url [local_xml_file] [options] Objects restored to a frozen state are readable create-symlink cloud_url target_url [options] Create a symbolic link read-symlink cloud_url [options] Read the description of the symbolic link file sign cloud_url [meta] [options] Generate an object download link probe file_name [options] Probe command, support a variety of function detection mkdir dir_name [options] Create a directory whose name has the suffix '/' in OSS cors bucket_url [local_xml_file] [options] Configure, query, or delete the CORS configuration of a bucket logging src_bucket_url target_bucket_url [options] Configure, query, or delete the log configuration of a bucket referer bucket_url referer [options] Set, query, or delete the referer configuration of a bucket listpart oss_object uploadid [options] Lists the chunk information of objects that have not completed the chunked upload getallpartsize bucket_url [options] Obtain the chunk size and sum of all incomplete multipart objects uploaded to the bucket appendfromfile local_file_name oss_object [options] Upload the local file content to the Appendable Object in OSS by append cat object [options] Outputs the contents of the file to standard output bucket-tagging bucket_url [tag_parameter] [options] Configure, query, or delete the tag configuration of a bucket bucket-encryption bucket_url [options] Set, query, or delete the encryption configuration of a bucket cors-options oss_url [options] Send HTTP options requests to OSS for CORS detection style bucket_url [local_xml_file] [style_name] [options] Add, query, delete, or list image styles for buckets lifecycle bucket_url local_xml_file [options] Configure, query, or delete the lifecycle configuration of a bucket website bucket_url local_xml_file [options] Configure, query, or delete the website configuration of a bucket bucket-qos bucket_url [local_xml_file] [options] Configure, query, or delete the QoS configuration of a bucket user-qos [local_file] [options] Query the QoS configuration of the user bucket-versioning bucket_url [versioning_parameter] [options] Set and query the versioning configuration of the bucket du bucket_url [options] Obtain the amount of bucket or the amount of storage occupied by a specified prefix (directory). bucket-policy bucket_url [local_json_file] [options] Configure, query, or delete the bucket's policy configuration request-payment bucket_url [payment_parameter] [options] Configure and query the visitor payment configuration of the bucket object-tagging cloud_url [tag_parameter] [options] Set, query, or delete the tag configuration of an object inventory bucket_url [local_xml_file] [id] [options] Add, query, delete, or list bucket configurations revert-versioning cloud_url [options] Reverts an object from a deleted state to a recent multi-version state sync src dest [options] Synchronize local file directories or OSS Prefix from the source to the destination worm command_name bucket_url [days] [wormId] [options] Configure, delete, modify, and commit the Worm configuration of a bucket lrb [conf_file] [options] List buckets in a region replication bucket_url [local_xml_file|ruleID] [options] Cross-region synchronization configuration management of buckets bucket-cname bucket_url [options] Manage bucket cname and cname token configuration lcb [options] List cloud box information access-monitor bucket_url local_xml_file [options] Set and query the access monitor configuration of the bucket resource-group bucket_url local_xml_file [options] Set and query the resource group configuration of the bucket Additional Commands: help [command] Gets help documentation for the command config [options] Create a configuration file to store configuration items hash file_url [options] Calculate the CRC64 or MD5 of the local file update [options] 更新ossutil ``` ### **操作** ### **上传**[(文档链接)](https://help.aliyun.com/zh/oss/developer-reference/upload-objects-6?spm=a2c4g.11186623.0.0.55e143a3peLdxV) 示例说明如下: * 本地文件:examplefile.txt(根目录下的文件) * 本地文件夹:localfolder(根目录下的文件夹) * 目标Bucket:examplebucket * 目标Bucket指定目录:desfolder ossutil支持将本地文件上传到OSS,示例如下: * 上传单个文件 上传文件时,如果不指定上传至OSS的文件名,则默认使用原文件名进行保存;如果指定文件名,则按照指定的文件名保存在OSS中。 ~~~bash ./ossutil64 cp examplefile.txt oss://examplebucket/desfolder/ ~~~ * 仅上传文件夹内的文件 使用cp命令时增加\-r选项,可以只将本地文件夹内的文件上传到OSS指定路径。 ~~~bash ./ossutil64 cp -r localfolder/ oss://examplebucket/desfolder/ ~~~ >[danger]window同理,ossutil64和ossutil.bat在同一文件夹下,我们打开ossutil.bat则无需在指定绝对路径而是直接`ossutil64 cp -r localfolder/ oss://examplebucket/desfolder/`否则需要指定完整的执行文件路径`E:\ossutil-v1.7.17-windows-amd64.exe cp -r localfolder/ oss://examplebucket/desfolder/` * 上传文件夹及文件夹内的文件 使用cp命令时增加\-r选项,并在OSS指定路径下添加本地文件夹名称,可以将本地文件夹以及文件夹内的文件上传到OSS指定路径。 ~~~bash ./ossutil64 cp -r localfolder/ oss://examplebucket/desfolder/localfolder/ ~~~ >[danger]windows系统将J:\BaiduNetdiskDownload\Media\Oimages\hello\ 文件夹下的内容上传到名字叫ava的Bucket下的test/目录下 ``` ossutil64 cp -r J:\BaiduNetdiskDownload\Media\Oimages\hello\ oss://ava/test/hello/ ``` J:\BaiduNetdiskDownload\Media\Oimages\K\ 文件夹下的内容上传到名字叫ava的Bucket的根目录下 ``` ossutil64 cp -r J:\BaiduNetdiskDownload\Media\Oimages\K\ oss://aviva/K/ ``` * 上传单个文件并指定\--meta选项 上传文件的同时可以使用\--meta选项设置文件的meta信息,其内容格式为`header:value#header:value...`。 ~~~bash ./ossutil64 cp examplefile.txt oss://examplebucket/desfolder/examplefile.txt --meta=Cache-Control:no-cache#Content-Encoding:gzip ~~~ * 上传文件夹并跳过已有文件 批量上传失败重传时,可以指定\--update(可缩写为\-u)选项跳过已经上传成功的文件,实现增量上传。示例如下: ~~~bash ./ossutil64 cp -r localfolder/ oss://examplebucket/desfolder/ -u ~~~ * 上传文件到开通了请求者付费模式的Bucket ~~~bash ./ossutil64 cp localfolder/examplefile.txt oss://examplebucket/ --payer=requester ~~~ * 仅上传当前目录下的文件,忽略子目录 ~~~bash ./ossutil64 cp localfolder/ oss://examplebucket/desfolder/ --only-current-dir -r ~~~ * 上传时不为目录生成Object OSS的目录是用一个0 KB大小,名称以正斜线(/)结尾的Object模拟的。上传时增加\--disable-dir-object参数,ossutil不会为该目录生成Object,但您仍可以在OSS控制台看到对应的目录结构。当您删除目录内的文件时,该目录也会消失。 ~~~bash ./ossutil64 cp localfolder/ oss://examplebucket/desfolder/ --disable-dir-object -r ~~~ * 上传软链接子目录下的文件 ~~~bash ./ossutil64 cp localfolder/ oss://examplebucket/desfolder/ --enable-symlink-dir -r ~~~ * 上传时忽略所有的软链接子文件以及软链接子目录 ~~~bash ./ossutil64 cp localfolder/ oss://examplebucket/desfolder/ -r --disable-all-symlink ~~~