• Stars
    star
    907
  • Rank 48,661 (Top 1.0 %)
  • Language
    Python
  • License
    MIT License
  • Created over 8 years ago
  • Updated 29 days ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Aliyun OSS SDK for Python

Alibaba Cloud OSS SDK for Python

https://travis-ci.org/aliyun/aliyun-oss-python-sdk.svg?branch=master https://coveralls.io/repos/github/aliyun/aliyun-oss-python-sdk/badge.svg?branch=master

README of Chinese <https://github.com/aliyun/aliyun-oss-python-sdk/blob/master/README-CN.rst>

Overview

Alibaba Cloud Object Storage Python SDK 2.x. This version is not compatible with the previous version (Version 0.x). The package name is oss2 to avoid conflict with previous versions.

The SDK of this version is dependent on the third-party HTTP library requests and crcmod. Install the SDK following the methods below.

Note:

This version does not contain the osscmd command line tool.

Running environment

Python 2.6(not recommended),2.7,3.3(not recommended),3.4,3.5,3.6

Note:
Python 2.6 is not recommended because it is no longer supported by the Python core team. Do not use Python 3.3.0 or 3.3.1. Refer to Python Issue 16658.

Installing

Install the official release version through PIP (taking Linux as an example):

$ pip install oss2

You can also install the unzipped installer package directly:

$ sudo python setup.py install

Getting started

# -*- coding: utf-8 -*-

import oss2

endpoint = 'http://oss-cn-hangzhou.aliyuncs.com' # Suppose that your bucket is in the Hangzhou region.

auth = oss2.Auth('<Your AccessKeyID>', '<Your AccessKeySecret>')
bucket = oss2.Bucket(auth, endpoint, '<your bucket name>')

# The object key in the bucket is story.txt
key = 'story.txt'

# Upload
bucket.put_object(key, 'Ali Baba is a happy youth.')

# Download
bucket.get_object(key).read()

# Delete
bucket.delete_object(key)

# Traverse all objects in the bucket
for object_info in oss2.ObjectIterator(bucket):
    print(object_info.key)

For more examples, refer to the code under the "examples" directory.

Handling errors

The Python SDK interface will throw an exception in case of an error (see oss2.exceptions sub-module) unless otherwise specified. An example is provided below:

try:
    result = bucket.get_object(key)
    print(result.read())
except oss2.exceptions.NoSuchKey as e:
    print('{0} not found: http_status={1}, request_id={2}'.format(key, e.status, e.request_id))

Setup Logging

The following code can set the logging level of 'oss2'.
import logging
logging.getLogger('oss2').setLevel(logging.WARNING)

Testing

First set the required AccessKeyId, AccessKeySecret, endpoint and bucket information for the test through environment variables (Do not use the bucket for the production environment). Take the Linux system for example:

$ export OSS_TEST_ACCESS_KEY_ID=<AccessKeyId>
$ export OSS_TEST_ACCESS_KEY_SECRET=<AccessKeySecret>
$ export OSS_TEST_ENDPOINT=<endpoint>
$ export OSS_TEST_BUCKET=<bucket>

$ export OSS_TEST_STS_ID=<AccessKeyId for testing STS>
$ export OSS_TEST_STS_KEY=<AccessKeySecret for testing STS>
$ export OSS_TEST_STS_ARN=<Role ARN for testing STS>

Run the test in the following method:

$ nosetests                          # First install nose

You can set environment variable to test auth v2:

$ export OSS_TEST_AUTH_VERSION=v2

More resources

Contacting us

License

More Repositories

1

oss-browser

OSS Browser 提供类似windows资源管理器功能。用户可以很方便的浏览文件,上传下载文件,支持断点续传等。
JavaScript
3,111
star
2

aliyun-openapi-java-sdk

Alibaba Cloud SDK for Java
Java
1,379
star
3

aliyun-oss-java-sdk

Aliyun OSS SDK for Java
Java
1,195
star
4

alibaba-cloud-sdk-go

Alibaba Cloud SDK for Go
Go
1,104
star
5

alicloud-android-demo

Java
982
star
6

aliyun-openapi-python-sdk

Alibaba Cloud SDK for Python
Python
980
star
7

aliyun-oss-php-sdk

Aliyun OSS SDK for PHP
PHP
975
star
8

aliyun-oss-go-sdk

Aliyun OSS SDK for Go
Go
933
star
9

darabonba

Darabonba 是一种用于 OpenAPI 的 DSL 语言,可以用来生成多语言的 SDK、Code Sample、Test Case 等代码
JavaScript
894
star
10

alibabacloud-alfa

阿里云微前端解决方案
TypeScript
838
star
11

aliyun-oss-android-sdk

Android SDK for aliyun object storage service
Java
793
star
12

aliyun-cli

Alibaba Cloud CLI
Go
770
star
13

ossfs

Export s3fs for aliyun oss.
C++
718
star
14

aliyun-openapi-php-sdk

[Abandoned] Open API SDK for PHP developers
PHP
605
star
15

terraform-provider-alicloud

Terraform AliCloud provider
Go
573
star
16

aliyun-openapi-net-sdk

Alibaba Cloud SDK for .NET
C#
534
star
17

rds_dbsync

围绕 PostgreSQL Greenplum ,实现易用的数据的互迁功能项目
C
528
star
18

openapi-sdk-php

Alibaba Cloud SDK for PHP
PHP
501
star
19

iotkit-embedded

高速镜像: https://code.aliyun.com/linkkit/c-sdk
C
492
star
20

aliyun-oss-ios-sdk

iOS SDK for aliyun object storage service
Objective-C
450
star
21

alicloud-ios-demo

Demos for AMS iOS SDKs
Objective-C
427
star
22

ossutil

A user friendly command line tool to access AliCloud OSS.
Go
427
star
23

aliyun-odps-python-sdk

ODPS Python SDK and data analysis framework
Python
407
star
24

api-gateway-demo-sign-java

aliyun api gateway request signature demo by java
Java
371
star
25

alibabacloud-microservice-demo

An Alibaba Cloud native microservice demo powered by Apache Dubbo and Spring Cloud Alibaba
Java
368
star
26

aliyun-oss-csharp-sdk

Aliyun OSS SDK for C#
C#
360
star
27

NeWCRFs

Python
344
star
28

surftrace

surftrace is a tool that allows you to surf the linux kernel
Python
332
star
29

conditional-lane-detection

Python
328
star
30

aliyun-log-jaeger

Go
294
star
31

tablestore-examples

Example code for aliyun tablestore.
Java
236
star
32

tablestore-timeline

TableStore-Timeline Model for Social scene
Java
236
star
33

coolbpf

C
222
star
34

openapi-sdk-php-client

Official repository of the Alibaba Cloud Client for PHP
PHP
214
star
35

aliyun-log-c-sdk

Aliyun LOG Producer for C/C++
C
212
star
36

aliyun-log-logback-appender

Java
176
star
37

openapi-core-nodejs-sdk

OpenAPI POP core SDK for Node.js
JavaScript
175
star
38

aliyun-log-android-sdk

Java
174
star
39

alibabacloud-jindodata

alibabacloud-jindodata
170
star
40

aliyun-emapreduce-datasources

Extended datasource support for Spark/Hadoop on Aliyun E-MapReduce.
Scala
168
star
41

aliyun-log-python-sdk

Use python to manage, produce and consume data with Aliyun Log Service.
Python
161
star
42

aliyun-oss-react-native

Objective-C
148
star
43

aliyun-apsaradb-hbase-demo

C++
147
star
44

data-mapping-component

A React Component which focus on Data-Mapping & Table-Field-Mapping.(基于React的数据/表字段映射组件)
JavaScript
146
star
45

aliyun-oss-c-sdk

Aliyun OSS SDK for C
C
144
star
46

django-oss-storage

Django storage backends for AliCloud OSS.
Python
142
star
47

aliyun-oss-ruby-sdk

Aliyun OSS SDK for Ruby
Ruby
138
star
48

ram-policy-editor

AliCloud RAM Policy Editor for OSS
JavaScript
135
star
49

serverless-aliyun-function-compute

Serverless Alibaba Cloud Function Compute Plugin – Add Alibaba Cloud Function Compute support to the Serverless Framework
JavaScript
133
star
50

react-visual-modeling

A DAG React Component for visualization modeling, suitable for UML, database modeling, data warehouse construction.(一个基于React的数据可视化建模的DAG图,适用于UML,数据库建模,数据仓库建设等业务)
JavaScript
132
star
51

alibabacloud-console-components

阿里云企业云管理平台 UI 组件库
TypeScript
131
star
52

fc-nodejs-sdk

The Node.js SDK of FunctionCompute.
JavaScript
130
star
53

aliyun-log-java-sdk

Java
130
star
54

aliyun-cms-grafana

JavaScript
127
star
55

aliyun-log-java-producer

Aliyun LOG Java Producer
Java
124
star
56

alibabacloud-quantization-networks

alibabacloud-quantization-networks
Python
122
star
57

aliyun-emapreduce-demo

Java
121
star
58

aliyun-odps-jdbc

JDBC Driver for ODPS
Java
118
star
59

alicloud-ams-demo

C#
117
star
60

aliyun-maxcompute-data-collectors

Java
113
star
61

alibabacloud-iot-device-sdk

alibaba cloud for iot device javascript SDK , connect with linkplatform , run at node/broswer/winxin min program /ali min program. 阿里云IoT物联网平台javascript版本sdk,可以运行在node/broswer/winxin min program /ali min program. 阿里云IoT物联网平台javascript版本sdk,可以运行在node/broswer/winxin min program /ali min program
JavaScript
110
star
62

api-gateway-nodejs-sdk

The API Gateway SDK for Node.js
JavaScript
104
star
63

MaxCompute-Spark

MaxCompute spark demo for building a runnable application.
Scala
104
star
64

gm-jsse

开源国密通信纯 Java JSSE 实现
Java
95
star
65

cloud-design

阿里云前端组件库,由专有云&公有云前端团队共建
CSS
95
star
66

aliyun-openapi-cpp-sdk

Alibaba Cloud SDK for C++
C++
90
star
67

aliyun-odps-console

ODPS Console Source Code.
Java
90
star
68

aliyun-tablestore-nodejs-sdk

Aliyun TableStore(原OTS) SDK for Node.js
JavaScript
88
star
69

aliyun-odps-java-sdk

ODPS SDK for Java Developers
Java
85
star
70

iotx-api-demo

PHP
83
star
71

aliyun-log-ios-sdk

Aliyun LOG iOS SDK
Swift
82
star
72

algorithm-base

让算法工程化更简单
Python
81
star
73

aliyun-openapi-nodejs-sdk

Alibaba Cloud SDK for Node.js
JavaScript
80
star
74

plugsched

Live upgrade Linux kernel scheduler subsystem
Python
77
star
75

DCT-Mask

Python
76
star
76

alibabacloud-redis-training-demo

Java
76
star
77

aliyun-oss-php-sdk-laravel

A Laravel service provider for the AliCloud OSS SDK for PHP
PHP
75
star
78

aliyun-tablestore-go-sdk

TableStore SDK for Golang
Go
75
star
79

fc-docker

Dockerfiles for local building or running function of FC
Dockerfile
74
star
80

aliyun-specs

Aliyun Mobile Service CocoaPods specs.
Ruby
74
star
81

dro-sfm

Python
74
star
82

packagist-mirror

Alibaba Cloud Packagist Mirror
Go
73
star
83

alibabacloud-console-design

阿里云管平台研发解决方案
TypeScript
73
star
84

elasticsearch-repository-oss

Java
72
star
85

alibabacloud-sdk

Tea
72
star
86

react-monitor-dag

A React-based operation/monitoring DAG diagram.(基于React的运维/监控DAG图)
JavaScript
68
star
87

aliyun-log-php-sdk

PHP
66
star
88

aliyun-tsdb-java-sdk

Aliyun TSDB SDK for Java
Java
64
star
89

aliyun-log-log4j-appender

aliyun-log-log4j-appender
Java
63
star
90

aliyun_assist_client

Aliyun Assist Client 阿里云 云助手
Go
62
star
91

fc-java-sdk

The Java SDK of FunctionCompute.
Java
61
star
92

alibabacloud-hologres-connectors

alibabacloud-hologres-connectors
Java
61
star
93

oss-ftp

The ftp proxy for Aliyun OSS.
Python
61
star
94

aliyun-log-cli

Command Line Interface for Aliyun Log Service
Python
59
star
95

csb-sdk

The CSB-SDK is a client-side invocation SDK for HTTP or Web Service API opened by the CSB (Cloud Service Bus) product. It is responsible for invoking the open API and signing the request information.
Java
58
star
96

aliyun-log-flink-connector

flink log connector
Java
58
star
97

ossimport

Data migration tool
57
star
98

oss-emulator

OSS Emulator
Ruby
57
star
99

fc-python-sdk

The python sdk of Aliyun FunctionCompute
Python
55
star
100

aliyun-log-dotnetcore-sdk

C#
54
star