Skip to content

增加图片持久化功能 #93

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 0 additions & 125 deletions README-CN.md

This file was deleted.

180 changes: 82 additions & 98 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,95 +1,79 @@
# Alibaba Cloud OSS SDK for C#

# Aliyun OSS SDK for C#

[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE)
[![GitHub Version](https://badge.fury.io/gh/aliyun%2Faliyun-oss-csharp-sdk.svg)](https://badge.fury.io/gh/aliyun%2Faliyun-oss-csharp-sdk)
[![GitHub version](https://badge.fury.io/gh/aliyun%2Faliyun-oss-csharp-sdk.svg)](https://badge.fury.io/gh/aliyun%2Faliyun-oss-csharp-sdk)
[![Build Status](https://travis-ci.org/aliyun/aliyun-oss-csharp-sdk.svg?branch=master)](https://travis-ci.org/aliyun/aliyun-oss-csharp-sdk)

## [README of Chinese](https://github.com/aliyun/aliyun-oss-csharp-sdk/blob/master/README-CN.md)
## 补充功能
- 增加阿里云OSS图片处理持久化功能
- ![success](/doc/success.jpg)
- ![demo](/doc/demo.jpg)
- 原图:[https://itsvse.oss-cn-hangzhou.aliyuncs.com/test/itsvse.jpg](https://itsvse.oss-cn-hangzhou.aliyuncs.com/test/itsvse.jpg)
- 处理后:[https://itsvse.oss-cn-hangzhou.aliyuncs.com/test/itsvse_demo.jpg](https://itsvse.oss-cn-hangzhou.aliyuncs.com/test/itsvse_demo.jpg)
- [OSS图片处理6.0工具](https://gosspublic.alicdn.com/image/index.html)
#### 代码(Process Object)
```csharp
ProcessObjectSample.ProcessObject(bucketName, "test/itsvse.jpg", "image/watermark,type_d3F5LXplbmhlaQ,size_30,text_aHR0cHM6Ly93d3cuaXRzdnNlLmNvbS8,color_FF0000,t_90,g_se,x_10,y_10", "test/itsvse_demo.jpg");
```


## About
Alibaba Cloud Object Storage Service (OSS) is a cloud storage service provided by [Alibaba Cloud](https://www.aliyun.com), featuring massive capacity, security, a low cost, and high reliability.
- The OSS C# SDK is built based on [OSS REST API](https://help.aliyun.com/document_detail/31948.html).
- OSS C# SDK[Online Documentation](http://gosspublic.alicdn.com/AliyunNetSDK/international/apidocs/latest/index.html).
## 关于
- 阿里云对象存储(Object Storage ServiceOSS),是[阿里云](https://www.aliyun.com)对外提供的海量,安全,低成本,高可靠的云存储服务。
- OSS C# SDK基于[OSS REST API](https://help.aliyun.com/document_detail/31948.html)构建。
- OSS C# SDK[在线文档](http://gosspublic.alicdn.com/AliyunNetSDK/apidocs/latest/index.html)

## Version
- Current version: 2.9.1.
## 版本
- 当前版本:2.9.1

## Run environment
## 运行环境

### Windows
- Applicable to `.NET 2.0` or above.
- Applicable to `Visual Studio 2010` or above.
- 适用于`.NET 2.0` 及以上版本
- 适用于`Visual Studio 2010`及以上版本

### Linux/Mac
- Applicable to `Mono 3.12` or above.
### .Net Core
- Applicable to `.net core 2.0` or above
## Install OSS C# SDK
### Install in Windows
#### Install the SDK through NuGet
- If NuGet hasn't been installed for Visual Studio, install [NuGet](http://docs.nuget.org/docs/start-here/installing-nuget) first.
- After NuGet is installed, access Visual Studio to create a project or open an existing project, and then select `TOOLS` > `NuGet Package Manager` > `Manage NuGet Packages for Solution`.
- Type `aliyun.oss.sdk` in the search box and click *Search*, find `Aliyun.OSS.SDK` or `Aliyun.OSS.SDK.NetCore` in the search results, select the latest version, and click *Install*. After installation, the SDK is added to the project.

#### Install the SDK through GitHub
- If Git hasn't been installed, install [Git](https://git-scm.com/downloads) first.
- Clone project via `git clone https://github.com/aliyun/aliyun-oss-csharp-sdk.git`.
- After the source code is downloaded, install the SDK by entering `Install via Project Introduction`.

#### Install the SDK through DLL reference
- Download the SDK packagefrom the Alibaba Cloud OSS official website. Unzip the package and you will find the ***Aliyun.OSS.dll*** file in the *bin* directory.
- In the Visual Studio, access `Solution Explorer`, select your project, right click *Project Name*, select `Add Reference` from the pop-up menu.
In the `Reference Manager` dialog box, click *Browse*, find the directory that the SDK is unzipped to, select the ***Aliyun.OSS.dll*** file in the *bin* directory, and click *OK*.

#### Install the SDK through project introduction
- If you have downloaded the SDK package or the source code from GitHub and you want to install the SDK package using the source code, you can right click `Solution Explorer` and select `Add` > `Existing Projects` from the pop-up menu.
- In the pop-up dialog box, select the `aliyun-oss-sdk.csproj` file, and click *Open*.
- Right click *Your Projects* and select `Add Reference`. In the `Reference Manager` dialog box, click the `Projects` tab, select the ***aliyun-oss-sdk*** project, and click *OK*.

### Install in Unix/Mac
#### Install the SDK through NuGet
- In `Xamarin`, create a project or open an existing project, and select `Tools` > `Add NuGet Packages`.
- Type `aliyun.oss.sdk` in the search box and click *Search*, find 'Aliyun.OSS.SDK' in the search results, select the latest version, and click `Add Package`. After installation, the SDK is added to the project.

#### Install the SDK through GitHub
- If Git hasn't been installed, install [Git](https://git-scm.com/downloads) first.
- Clone project via `git clone https://github.com/aliyun/aliyun-oss-csharp-sdk.git`.
- After the source code is downloaded, open it in *Xamarin*. Compile the *aliyun-oss-sdk* project in ***Release*** mode to generate the `Aliyun.OSS.dll` file. Then install the SDK through *DLL reference*.

#### Install the SDK through DLL reference
- Download the SDK package from Alibaba Cloud OSS official website. Unzip the package and you will find the ***Aliyun.OSS.dll*** file in the *bin* directory.
- In the Xamarin, access `Solution`, select your project, right click *Project Name*, select `Reference`' > `Edit References` from the pop-up menu.
In the `Edit References` dialog box, click `.Net Assembly` > `Browse`. Find the directory that the SDK is unzipped to, select the `Aliyun.OSS.dll` file in the *bin* directory, and click *Open*.
### Running with .Net core runtime
Starting with version 2.9, OSS SDK supports the .net core 2.0 platform.
#### Installing .Net core SDK & runtime
##### .Net Core SDK 2.0 (or above)
To build apps for .Net core 2.0, you need to install the .Net core 2.0 SDK.
Windows:https://www.microsoft.com/net/download/windows/build

MacOS: https://www.microsoft.com/net/download/macos

Linux: https://www.microsoft.com/net/download/linux/build

##### .Net core runtime 2.0 (or above)
If you just want to run apps of .Net core 2.0, then you need to install the runtime:
Windows:https://www.microsoft.com/net/download/windows/run

MacOS: https://www.microsoft.com/net/download/macos/run

Linux: https://www.microsoft.com/net/download/linux/run

#### Compile OSS SDK with .net core 2.0
- cd to the root folder of OSS SDK.
- dotnet restore aliyun-oss-sdk-dotnetcore.sln
- dotnet build aliyun-oss-sdk-dotnetcore.sln

#### To run Samples
- Update the samples\Config.cs to update the config properties with your actual OSS AKs and endpoint.
- use the step above to build the whole solution
- cd to the folder where Aliyun.OSS.Samples.dll exists and then run: `dotnet Aliyun.OSS.Samples.dll`

## Quick use
#### Get the bucket list (List Bucket)
- 适用于`Mono 3.12` 及以上版本

## 安装方法
### Windows环境安装
#### NuGet安装
- 如果您的Visual Studio没有安装NuGet,请先安装 [NuGet](http://docs.nuget.org/docs/start-here/installing-nuget).
- 安装好NuGet后,先在`Visual Studio`中新建或者打开已有的项目,然后选择`<工具>`-`<NuGet程序包管理器>`-`<管理解决方案的NuGet程序包>`,
- 搜索`aliyun.oss.sdk`,在结果中找到`Aliyun.OSS.SDK`或`Aliyun.OSS.SDK.NetCore`,选择最新版本,点击安装,成功后添加到项目应用中。

#### GitHub安装
- 如果没有安装git,请先安装 [git](https://git-scm.com/downloads)
- git clone https://github.com/aliyun/aliyun-oss-csharp-sdk.git
- 下载好源码后,按照`项目引入方式安装`即可

#### DLL引用方式安装
- 从阿里云OSS官网下载SDK包,解压后bin目录包括了Aliyun.OSS.dll文件。
- 在Visual Studio的`<解决方案资源管理器>`中选择您的项目,然后右键`<项目名称>`-`<引用>`,在弹出的菜单中选择`<添加引用>`,
在弹出`<添加引用>`对话框后,选择`<浏览>`,找到SDK包解压的目录,在bin目录下选中`<Aliyun.OSS.dll>`文件,点击确定即可

#### 项目引入方式安装
- 如果是下载了SDK包或者从GitHub上下载了源码,希望源码安装,可以右键`<解决方案>`,在弹出的菜单中点击`<添加>`->`<现有项目>`。
- 在弹出的对话框中选择`aliyun-oss-sdk.csproj`文件,点击打开。
- 接下来右键`<您的项目>`-`<引用>`,选择`<添加引用>`,在弹出的对话框选择`<项目>`选项卡后选中`aliyun-oss-sdk`项目,点击确定即可。

### Unix/Mac环境安装
#### NuGet安装
- 先在`Xamarin`中新建或者打开已有的项目,然后选择`<工具>`-`<Add NuGet Packages>`。
- 搜索`aliyun.oss.sdk`,在结果中找到`Aliyun.OSS.SDK`,选择最新版本,点击`<Add Package>`,成功后添加到项目应用中。

#### GitHub安装
- 如果没有安装git,请先安装 [git](https://git-scm.com/downloads)
- git clone https://github.com/aliyun/aliyun-oss-csharp-sdk.git
- 下载好源码后,使用Xamarin打开,在Release模式下编译aliyun-oss-sdk项目,生成Aliyun.OSS.dll,然后通过DLL引用方式安装

#### DLL引用方式安装
- 从阿里云OSS官网下载SDK包,解压后bin目录包括了Aliyun.OSS.dll文件。
- 在Xamarin的`<解决方案>`中选择您的项目,然后右键`<项目名称>`-`<引用>`,在弹出的菜单中选择`<Edit References>`,
在弹出`<Edit References>`对话框后,选择`<.Net Assembly>-<浏览>`,找到SDK包解压的目录,在bin目录下选中`<Aliyun.OSS.dll>`文件,点击`<Open>`即可

## 快速使用
#### 获取存储空间列表(List Bucket)
```csharp
OssClient client = new OssClient(endpoint, accessKeyId, accessKeySecret);
var buckets = client.ListBuckets();
Expand All @@ -100,31 +84,31 @@ Linux: https://www.microsoft.com/net/download/linux/run
}
```

#### Create a bucket (Create Bucket)
#### 创建存储空间(Create Bucket
```csharp
OssClient client = new OssClient(endpoint, accessKeyId, accessKeySecret);
client.CreateBucket(bucketName);
```

#### Delete a bucket (Delete Bucket)
#### 删除存储空间(Delete Bucket
```csharp
OssClient client = new OssClient(endpoint, accessKeyId, accessKeySecret);
client.DeleteBucket(bucketName);
```

#### Upload a file (Put Object)
#### 上传文件(Put Object
```csharp
OssClient client = new OssClient(endpoint, accessKeyId, accessKeySecret);
client.PutObject(bucketName, key, filePathToUpload);
```

#### Download an object (Get Object)
#### 下载文件 (Get Object)
```csharp
OssClient client = new OssClient(endpoint, accessKeyId, accessKeySecret);
var object = ossClient.GetObject(bucketName, key);
```

#### Get the object list (List Objects)
#### 获取文件列表(List Objects
```csharp
OssClient client = new OssClient(endpoint, accessKeyId, accessKeySecret);
var listResult = client.ListObjects(bucketName);
Expand All @@ -134,20 +118,20 @@ Linux: https://www.microsoft.com/net/download/linux/run
}
```

#### Delete an object (Delete Object)
#### 删除文件(Delete Object)
```csharp
OssClient client = new OssClient(endpoint, accessKeyId, accessKeySecret);
client.DeleteObject(bucketName, key)
```

#### Others
- In the example above, if no exception was thrown, it indicates the execution was successful. Otherwise, it indicates the execution failed. More detailed examples can be found and run in the aliyun-oss-sample project.
#### 其它
- 上面的例子中,如果没有抛出异常则说明执行成功,否则失败,更详细的例子可以在aliyun-oss-sample项目中查看并运行。

## Notes
- If you want to run a sample project, you must set the aliyun-oss-sdk-sample project as the 'Startup Project' and add your own AccessKeyId, AccessKeySecret, buckets and keys, and then run the project.

## Contact us
- [Alibaba Cloud OSS official website](http://oss.aliyun.com).
- [Alibaba Cloud OSS official forum](http://bbs.aliyun.com).
- [Alibaba Cloud OSS official documentation center](http://www.aliyun.com/product/oss#Docs).
- Alibaba Cloud official technical support: [Submit a ticket](https://workorder.console.aliyun.com/#/ticket/createIndex).
## 注意事项
- 如果要运行sample,需要将aliyun-oss-sdk-sample项目设为`启动项目`,并添加您自己的AccessKeyId,AccessKeySecret,bucket,key等后即可运行。

## 联系我们
- [阿里云OSS官方网站](http://oss.aliyun.com)
- [阿里云OSS官方论坛](http://bbs.aliyun.com)
- [阿里云OSS官方文档中心](http://www.aliyun.com/product/oss#Docs)
- 阿里云官方技术支持:[提交工单](https://workorder.console.aliyun.com/#/ticket/createIndex)
Binary file added doc/demo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/success.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 5 additions & 3 deletions samples/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ public static void Main(string[] args)

try
{
CreateBucketSample.CreateBucket(bucketName);
ProcessObjectSample.ProcessObject(bucketName, "test/itsvse.jpg", "image/watermark,type_d3F5LXplbmhlaQ,size_30,text_aHR0cHM6Ly93d3cuaXRzdnNlLmNvbS8,color_FF0000,t_90,g_se,x_10,y_10", "test/itsvse_demo.jpg");

//CreateBucketSample.CreateBucket(bucketName);

//ListBucketsSample.ListBuckets();

Expand Down Expand Up @@ -99,9 +101,9 @@ public static void Main(string[] args)
//DeleteBucketSample.DeleteNoEmptyBucket(bucketName);

//SetObjectAclSample.SetObjectAcl(bucketName);

//GetObjectAclSample.GetBucketAcl(bucketName);

//ImageProcessSample.ImageProcess(bucketName);

//ProgressSample.Progress(bucketName);
Expand Down
Loading