public void _UpLoadFile(object value) { ObjectMetadata om = new ObjectMetadata(); UpLoadDataInfo uploadDataInfo = null; if (value is UpLoadDataInfo) { uploadDataInfo = (UpLoadDataInfo)value; } else { return; } client.DeleteObject(uploadDataInfo.bucket, uploadDataInfo.fileKey); client.PutObject(uploadDataInfo.bucket, uploadDataInfo.fileKey, uploadDataInfo.fs, om); }
public void UpLoadFile(string bucket, string fileKey, string sourcePath) { FileStream fs = null; UpLoadDataInfo uploadDataInfo = new UpLoadDataInfo(); try { fs = new FileStream(sourcePath, FileMode.Open, FileAccess.Read); } catch (IOException ioEx) //文件正在使用中,不能打开 { return; } uploadDataInfo.bucket = bucket; uploadDataInfo.fileKey = fileKey; uploadDataInfo.fs = fs; uploadThread = new Thread(new ParameterizedThreadStart(_UpLoadFile)); uploadProcess = new Thread(new ParameterizedThreadStart(_UpLoadProcess)); uploadThread.Start(uploadDataInfo); uploadProcess.Start(fs); }