1.需要使用七牛云在unity内图片上传,多次尝试无法成功
sdk版本:csharp-sdk-7.3.0
2.
string AccessKey = "xxx";
string SecretKey = "xxx";
Mac mac = new Mac(AccessKey, SecretKey);
// 上传文件名
string key = "key";
// 本地文件路径
string filePath = "D:\\Project\\Game\\Land_Client\\Assets\\PhotoTest\\4.jpg";
// 存储空间名
string Bucket = "game";
// 设置上传策略,详见:https://developer.qiniu.com/kodo/manual/1206/put-policy
PutPolicy putPolicy = new PutPolicy();
// 设置要上传的目标空间
putPolicy.Scope = Bucket;
// 上传策略的过期时间(单位:秒)
putPolicy.SetExpires(3600);
// 文件上传完毕后,在多少天后自动被删除
putPolicy.DeleteAfterDays = 1;
// 生成上传token
string token = Auth.CreateUploadToken(mac, putPolicy.ToJsonString());
Config config = new Config();
// 设置上传区域
config.Zone = Zone.ZONE_CN_South;
// 设置 http 或者 https 上传
config.UseHttps = true;
config.UseCdnDomains = true;
config.ChunkSize = ChunkUnit.U512K;
// 表单上传
UploadManager um = new UploadManager(config);
PutExtra pe = new PutExtra();
pe.ProgressHandler += delegate (long uploadedBytes, long totalBytes)
{
var str = string.Format("up:{0}, total:{1}", uploadedBytes, totalBytes);
Debug.Log(str);
};
HttpResult result = um.UploadFile(filePath, key, token, pe);
Debug.Log("form upload result: " + result.ToString());
3.无报错信息
4.没有解决思路,不知道哪个环节出了问题
您好,七牛的最新的c# sdk 是基于 .net 开发的,
unity-sdk的话,可以参考下这个试试
https://github.com/moohyeah/u...