You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using Volo.Abp.Application.Services;using System.IO;using Aliyun.OSS;using System.Security.AccessControl;
namespace Shentun.Peis.Books{
public static class QiNiuHelper {
// 阿里云账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM
// 用户进行API访问或日常运维,请登录RAM控制台创建RAM用户。
const string accessKeyId = "LTAI5tBNDdiV7JudVvaQhU1t"; const string accessKeySecret = "sA6k0TbeX8w2cv7YhcTed7wyt0EBdN";
// yourEndpoint填写Bucket所在地域对应的Endpoint。以华东1(杭州)为例,Endpoint
// 填写为https://oss-cn-hangzhou.aliyuncs.com。
const string endpoint = "https://oss-cn-beijing.aliyuncs.com"; // 填写Bucket名称。
const string bucketName = "whdshake";
public static void Upload_QiNiu() {
// 填写Object完整路径。Object完整路径中不能包含Bucket名称。
// 即:objectName为文件上传到阿里云OSS上的文件夹路径
var objectName = "imgae/222.png";
// 填写本地文件的完整路径。如果未指定本地路径,
// 则默认从示例程序所属项目对应本地路径中上传文件。
var localFilename = @"D:\aaa.png";
//System.Web.HttpContext.Current.Server.MapPath("imgae.png");
// 创建OssClient实例。
var client = new Aliyun.OSS.OssClient(endpoint, accessKeyId, accessKeySecret); try { // 上传文件。
client.PutObject(bucketName, objectName, localFilename); Console.WriteLine("1"); } catch (Exception ex) { Console.WriteLine(ex.Message); }
}
}
}
|