上传者: m0_37739818
|
上传时间: 2022-09-14 10:26:06
|
文件大小: 204KB
|
文件类型: DLL
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using Aliyun.OSS;
using UnityEditor;
using Aliyun.OSS.Common;
public class AliyunOss
{
// 创建OssClient实例。
OssClient client;
string endpoint = "https://oss-cn-shenzhen.aliyuncs.com";
string accessKeyId = "LTAIEs3jNeemGrVB";
string accessKeySecret = "LCBXE73BHFkxwfOHVS7FOe0GBTaZVM";
string bucketName = "zhandingbo";
string objectName = "modal";
//string localFilename = "Assets/StreamingAssets";
//string outPath = "Assets/StreamingAssets"; //Application.temporaryCachePath
string localFilename = "C:/Users/11854/Desktop/modal.png";
string outPath = "Assets/StreamingAssets"; //Application.temporaryCachePath
#region 单例
private static AliyunOss mSelf = null;
public static AliyunOss Instance
{
get
{
if (mSelf == null)
{
mSelf = new AliyunOss();
}
return mSelf;
}
}
AliyunOss()
{
client = new OssClient(endpoint, accessKeyId, accessKeySecret);
}
#endregion
public void OssAb(string path, string name)
{
try
{
// 上传文件。
Debug.Log(path + "-----------" + objectName + path + "/" + name);
// client.PutObject(bucketName, objectName + path + "/" + name, localFilename + path + "/" + name);
// client.PutObject(bucketName, objectName , localFilename);
client.PutObject(bucketName, path, name);
Debug.Log("Oss succeeded");
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
}
}