Jc.OSS
1.0.7
dotnet add package Jc.OSS --version 1.0.7
NuGet\Install-Package Jc.OSS -Version 1.0.7
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Jc.OSS" Version="1.0.7" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Jc.OSS --version 1.0.7
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Jc.OSS, 1.0.7"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Jc.OSS as a Cake Addin #addin nuget:?package=Jc.OSS&version=1.0.7 // Install Jc.OSS as a Cake Tool #tool nuget:?package=Jc.OSS&version=1.0.7
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Jc.OSS
阿里云oss存储桶操作模块
dotnet add package Jc.OSS
实例化
Jc.OSS.JcOSS oss = new Jc.OSS.JcOSS("bucketName","endPoint","accessKeyId","accessKeySecret");
创建存储桶
CreateBucket(string bucketName)
删除存储桶
DeleteBucket(string bucketName)
同步上传一个文件
/// <summary>
/// 同步_上传一个新文件
/// </summary>
/// <param name="key">存储桶key</param>
/// <param name="localFile">本地文件路径</param>
/// <returns></returns>
bool PutObject(string key, string localFile)
同步上传stream
/// <summary>
/// 同步_上传stream
/// </summary>
/// <param name="key"></param>
/// <param name="localFile"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public bool PutObject(string key, Stream localFile)
追加stream
/// <summary>
/// 追加上传stream
/// </summary>
/// <param name="key"></param>
/// <param name="stream"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public bool AppendObject(string key, Stream stream)
追加文件
/// <summary>
/// 追加上传文件
/// </summary>
/// <param name="key">存储桶key</param>
/// <param name="localFile">本地文件路径</param>
/// <returns></returns>
public bool AppendObject(string key, string localFile)
同步下载一个文件
/// <summary>
/// 同步_下载文件一个文件
/// </summary>
/// <param name="key">文件key</param>
/// <param name="localFilePath">本地保存文件的路径(全路径)</param>
/// <returns></returns>
bool GetObject(string key, string localFilePath)
同步获取文件内容
/// <summary>
/// 同步_获取文件信息
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public OssObject GetObject(string key)
删除一个文件夹
/// <summary>
/// 删除文件
/// </summary>
/// <param name="key">文件Key</param>
/// <returns></returns>
bool DeleteObject(string key)
判断文件是否存在
/// <summary>
/// 判断文件是否存在
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
bool IsObject(string key)
获取一个临时访问URL
/// <summary>
/// 获取临时访问Url
/// </summary>
/// <param name="key">文件Key</param>
/// <param name="Minutes">超时:分钟</param>
/// <returns></returns>
string GetObjectUrl(string key, int Minutes)
异步上传文件
/// <summary>
/// 异步上传文件
/// </summary>
/// <param name="key">key</param>
/// <param name="localFile">本地文件路径</param>
/// <param name="contentType"></param>
/// <param name="callback">void callback(IAsyncResult ar)</param>
public void PutObjectAsync(string key, string localFile, string contentType, PutCallBack callback)
//上传回调
void PutCallback(System.Net.HttpStatusCode code)
{
Console.WriteLine("put:"+code.ToString());
}
异步下载文件
/// <summary>
/// 异步下载一个文件
/// </summary>
/// <param name="key"></param>
/// <param name="callback"></param>
/// <returns></returns>
public bool GetObjectAsync(string key, GetCallBack callback)
//下载回调
void GetCallBack(OssObject obj)
{
if (obj.HttpStatusCode == HttpStatusCode.OK)
{
using (var fileStream = File.Create("local file path"))
{
obj.Content.CopyTo(fileStream);
}
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- Aliyun.OSS.SDK.NetCore (>= 2.13.0)
-
.NETStandard 2.1
- Aliyun.OSS.SDK.NetCore (>= 2.13.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.