public bool GetData(string fileKey, string baseKey, Action<UpdateProgressInfo> onProgress, ref string tempLocation) { try { //aliyun对于"a//b"这样的路径不认,只认"a/b" string fullFileKey = (SourceRoot + "/" + baseKey + "/" + fileKey).Replace("//", "/"); AliyunDownloadRequst downloadRequest = new AliyunDownloadRequst(BucketName, fullFileKey , tempLocation); AliyunTransfer.GetObject(downloadRequest); return true; } catch (Exception) { } return false; }
public ObjectMetadata GetObject(AliyunDownloadRequst downloadRequst) { ObjectMetadata ret = null; using (FileStream fs = new FileStream(downloadRequst.file, FileMode.Create)) { long totalBytes = GetObjectSize(downloadRequst.bucketName, downloadRequst.key); AliyunStream stream = new AliyunStream(fs); stream.WritePositionChangeEvent += delegate(long nowPosition, long _totalBytes) { downloadRequst.TransferFile(nowPosition, totalBytes); }; GetObjectRequest getObjectRequest = new GetObjectRequest(downloadRequst.bucketName, downloadRequst.key); ret = _ossClient.GetObject(getObjectRequest, stream); } return ret; }