我之前只开通了腾讯云的服务器,所以我从阿里云那里复制了一段UnityWebRequest的代码过来(为了省事我删除了显示进度条的部分),然后下载到本地之后错误提示access to the path ' ' is denied. 上百度查到是访问权限的问题,我应该是把所有权限都打开了的,也额外添加了everyone的读写权限,但还是不解决问题。但是我学着腾讯云教学部分的方法上传文件就没有问题,检查过下载链接也没有错。老师能帮忙看看是什么问题吗?
部分代码如下:
private void ShowDownLoadProcess()
{
if (asyncOperation != null && asyncOperation.isDone)
{
byte[] bytes = asyncOperation.webRequest.downloadHandler.data;
asyncOperation = null;
print(SavePath);
File.WriteAllBytes(SavePath, bytes);
}
}
public void DownLoad()
{
GetObjectWithUnityWebRequest("a.zip", @"D:\");
}
public void GetObjectWithUnityWebRequest(string filePath, string savePath)
{
SavePath = savePath;
StartCoroutine(GetObjectWithUnityWebRequest(filePath));
}
private IEnumerator GetObjectWithUnityWebRequest(string filePath)
{
string path = @"https://" + bucketName + "-" + APP_ID + "." + endPoint + "/" + filePath;
//path = @"https://penguin-demo-1312790960.cos.ap-guangzhou.myqcloud.com/a.zip";
//print(path);
UnityWebRequest unityWebRequest = UnityWebRequest.Get(path);
asyncOperation = unityWebRequest.SendWebRequest();
yield return asyncOperation;
}
ps:我昨天在那节课里提问过,但是评论区又挂了
同学你好,看同学的代码,还有几个解决方案都没有问题,可以上谷歌再找找看,实在不行可以换一种方法试试,另外问题提交Carson老师了,老师看到就会帮忙看看