阿里云oss初使用
一、购买
二、配置RAM权限
https://ram.console.aliyun.com/users
1、创建用户
2、创建完成后注意获取AccessKey ID、AccessKey Secret(只展示一次,后面会用到)
3、添加权限,这里全部权限都添加上(我也没有仔细看,选中前面几个,后面就默认全选了)
三、创建Bucket
https://oss.console.aliyun.com/bucket
四、安装对应的SDK
1、找到对应的SDK
https://help.aliyun.com/document_detail/32006.html
2、选择对应的语言(这里使用Python)
3、安装SDK
4、操作案例,按提示填写对应的信息,新建python文件
五、运行时的一个报错
oss2.exceptions.RequestError: {'status': -2, 'x-oss-request-id': '', 'details': "RequestError: HTTPSConnectionPool(host='laat.oss-cn-beijin.aliyuncs.com', port=443): Max retries exceeded with url: /exampleobject.txt (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fa8864b2320>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known',))"}
/Users/sunxinyang/Desktop/LaatUI/venv/bin/python /Users/sunxinyang/Desktop/LaatUI/LaatUI/apps/reports/views.py
Traceback (most recent call last):
File "/Users/sunxinyang/Desktop/LaatUI/venv/lib/python3.6/site-packages/urllib3/connection.py", line 175, in _new_conn
(self._dns_host, self.port), self.timeout, **extra_kw
File "/Users/sunxinyang/Desktop/LaatUI/venv/lib/python3.6/site-packages/urllib3/util/connection.py", line 72, in create_connection
for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/socket.py", line 745, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 8] nodename nor servname provided, or not known During handling of the above exception, another exception occurred: Traceback (most recent call last):
File "/Users/sunxinyang/Desktop/LaatUI/venv/lib/python3.6/site-packages/urllib3/connectionpool.py", line 710, in urlopen
chunked=chunked,
File "/Users/sunxinyang/Desktop/LaatUI/venv/lib/python3.6/site-packages/urllib3/connectionpool.py", line 386, in _make_request
self._validate_conn(conn)
File "/Users/sunxinyang/Desktop/LaatUI/venv/lib/python3.6/site-packages/urllib3/connectionpool.py", line 1040, in _validate_conn
conn.connect()
File "/Users/sunxinyang/Desktop/LaatUI/venv/lib/python3.6/site-packages/urllib3/connection.py", line 358, in connect
self.sock = conn = self._new_conn()
File "/Users/sunxinyang/Desktop/LaatUI/venv/lib/python3.6/site-packages/urllib3/connection.py", line 187, in _new_conn
self, "Failed to establish a new connection: %s" % e
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x7fa8864b2320>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known During handling of the above exception, another exception occurred: Traceback (most recent call last):
File "/Users/sunxinyang/Desktop/LaatUI/venv/lib/python3.6/site-packages/requests/adapters.py", line 450, in send
timeout=timeout
File "/Users/sunxinyang/Desktop/LaatUI/venv/lib/python3.6/site-packages/urllib3/connectionpool.py", line 786, in urlopen
method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
File "/Users/sunxinyang/Desktop/LaatUI/venv/lib/python3.6/site-packages/urllib3/util/retry.py", line 592, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='laat.oss-cn-beijin.aliyuncs.com', port=443): Max retries exceeded with url: /exampleobject.txt (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fa8864b2320>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known',)) During handling of the above exception, another exception occurred: Traceback (most recent call last):
File "/Users/sunxinyang/Desktop/LaatUI/venv/lib/python3.6/site-packages/oss2/http.py", line 49, in do_request
proxies=req.proxies))
File "/Users/sunxinyang/Desktop/LaatUI/venv/lib/python3.6/site-packages/requests/sessions.py", line 529, in request
resp = self.send(prep, **send_kwargs)
File "/Users/sunxinyang/Desktop/LaatUI/venv/lib/python3.6/site-packages/requests/sessions.py", line 645, in send
r = adapter.send(request, **kwargs)
File "/Users/sunxinyang/Desktop/LaatUI/venv/lib/python3.6/site-packages/requests/adapters.py", line 519, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='laat.oss-cn-beijin.aliyuncs.com', port=443): Max retries exceeded with url: /exampleobject.txt (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fa8864b2320>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known',)) During handling of the above exception, another exception occurred: Traceback (most recent call last):
File "/Users/sunxinyang/Desktop/LaatUI/LaatUI/apps/reports/views.py", line 14, in <module>
result = bucket.put_object('exampleobject.txt', 'Hello OSS')
File "/Users/sunxinyang/Desktop/LaatUI/venv/lib/python3.6/site-packages/oss2/api.py", line 567, in put_object
resp = self.__do_object('PUT', key, data=data, headers=headers)
File "/Users/sunxinyang/Desktop/LaatUI/venv/lib/python3.6/site-packages/oss2/api.py", line 2529, in __do_object
return self._do(method, self.bucket_name, key, **kwargs)
File "/Users/sunxinyang/Desktop/LaatUI/venv/lib/python3.6/site-packages/oss2/api.py", line 227, in _do
resp = self.session.do_request(req, timeout=self.timeout)
File "/Users/sunxinyang/Desktop/LaatUI/venv/lib/python3.6/site-packages/oss2/http.py", line 51, in do_request
raise RequestError(e)
oss2.exceptions.RequestError: {'status': -2, 'x-oss-request-id': '', 'details': "RequestError: HTTPSConnectionPool(host='laat.oss-cn-beijin.aliyuncs.com', port=443): Max retries exceeded with url: /exampleobject.txt (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fa8864b2320>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known',))"} Process finished with exit code 1
解决方案:
安装如下插件
pip install cryptography pip install pyOpenSSL pip install certifi
阿里云oss初使用的更多相关文章
- 如何用云存储和CDN加速网站图片视频、阿里云OSS的使用(转)
总有人说阿里云主机带宽小,那只是因为你还停留在单机架构上. 阿里的架构设计,云主机主要用来跑程序的,附件的存储和访问主要靠OSS. 有人又会说了,OSS按存储费+流量双重计费伤不起,只是你不知道OSS ...
- phpcmsv9 阿里云OSS云存储整合教程
该教程算不上是phpcmsv9阿里云oss插件,所以整个修改及其代码覆盖前请一定记得备份.还有一点就是后台发布文章时上传的附件还是会保存在你的服务器上,基于以下原因:1.个人的需求是前台页面需要使用t ...
- angulaijs中的ng-upload-file与阿里云oss服务的结合,实现在浏览器端上传文件到阿里云(速度可以达到1.5M)
2015-10-26 angularjs结合aliyun浏览器端oos文件上传加临时身份验证例子 在服务端获取sts 源码: public class StsServiceSample { // 目前 ...
- 阿里云 OSS+CDN
https://promotion.aliyun.com/ntms/ossedu2.html https://www.aliyun.com/act/aliyun/ossdoc.html 对象存储(Ob ...
- 阿里云oss上传图片
1.首先我们要下载阿里云oss的sdk包:(可以下载原版的,改过的通用版在本人的百度云,嘎嘎嘎~) 2.下载好之后放到项目文件目录里面 3.要在需要的控制器引用这个sdk文件例如: include(& ...
- discuz 使用阿里云OSS
discuz 使用阿里云OSS (转)http://bbs.aliyun.com/read/239257.html 说明:我绑定了二级域名,本演示采用二级域名oss来介绍,我实际使用的是二级域名pic ...
- (转)云存储:阿里云OSS 、又拍云和 七牛 的比较
阿里OSS:好处就是,那是一套完整的体系,存储,数据库,CDN,服务器,阿里都可以给你全包.缺点,费用对于没有盈利的网站来说太高了,好像定位就是给那些高端客户使用的,而且CDN,OSS的流量是分开收费 ...
- 上传图片到阿里云OSS和获取上传图片的外网url的步骤
啥都不说 直接上代码 1.html: <form action="/bcis/api/headImgUpload.json" method="post" ...
- laravel下使用阿里云oss上传图片
对小公司而言,使用阿里云oss比直接买硬盘要划算的多,不管从存储性价比上还是从网速负载上.最近因为公司的项目有比较大的图片存储访问需求,所以决定使用阿里云的oss. 在研究了一下以后,摆着不自己造轮子 ...
- 在OneThink(ThinkPHP3.2.3)中整合阿里云OSS的PHP-SDK2.0.4,实现Web端直传,服务端签名直传并设置上传回调的实现流程
在OneThink(ThinkPHP3.2.3)中整合阿里云OSS的PHP-SDK2.0.4,实现本地文件上传流程 by shuijingwan · 2016/01/13 1.SDK安装 github ...
随机推荐
- 分布式注册服务中心etcd在云原生引擎中的实践
作者:王雷 etcd是什么 etcd是云原生架构中重要的基础组件,由CNCF孵化托管.ETCD是用于共享配置和服务发现的分布式,一致性的KV存储系统,是CoreOS公司发起的一个开源项目,授权协议为A ...
- css实习滤镜效果(背景图模糊)
模糊实例 图片使用高斯模糊效果: img { -webkit-filter: blur(5px); /* Chrome, Safari, Opera */ filter: blur(5px); } c ...
- JavaScript:箭头函数:作为参数进行传参
之前已经说过,JS的函数,也是对象,而函数名是一个变量,是可以进行传参的,也即函数是可以被传参的. 只要是函数,都可以被传参,但是箭头函数的语法更为灵活,所以更方便进行传参. 如上图所示,fun1是一 ...
- 百度智能云 API调用PythonSDK
百度智能云 API调用PythonSDK 这是一个用于百度云部分开放AI功能的Python库.主要为ORC功能,可以对各种图像文件进行文字识别,包括车牌.手写文字.通用文字.人脸发现.人脸比对和人流量 ...
- [seaborn] seaborn学习笔记7-常用参数调整Adjustment of Common Parameters
7 常用参数调整Adjustment of Common Parameters(代码下载) 主要讲述关于seaborn通用参数设置方法,该章节主要内容有: 主题设置 themes adjustment ...
- [数据结构]克鲁斯卡尔(Kruskal)算法
算法的概念 与Prim算法从顶点开始扩展最小生成树不同,Kruskal算法是一种按权值的递增次序选择合适的边来构造最小生成树的方法.假设N=(V,E)是连通网,对应的最小生成树T=(Vt,Et),Kr ...
- [数据结构]广度优先搜索算法(Breadth-First-Search,BFS)
广度优先搜索的概念 广度优先搜索(BFS)类似于二叉树的层序遍历算法,它的基本思想是:首先访问起始顶点v,然后由v出发,依次访问v的各个未被访问过的邻接顶点w1,w2,w3-.wn,然后再依次访问w1 ...
- 题解 CF1579G Minimal Coverage
CF1579G Minimal Coverage dp好题! link to the problem 解法 首先需要观察到:如果最长线段的长度为\(maxL\),那么答案不可能超过\(2maxL\) ...
- ZROI3
题解 ZROI3 T1 与<滑动窗口>类似,用单调队列维护 #include <queue> #include <cstdio> #include <cstr ...
- C#爬虫开发小结
前言 2023年以来一直很忙,临近春节,各种琐事更多,但鸽了太久没写文章总是不舒坦,忙中偷闲来记录下最近用C#写爬虫的一些笔记. 爬虫一般都是用Python来写,生态丰富,动态语言开发速度快,调试也很 ...