From 15e6a5d9c38ca55bce81f7f9e6ff902919af8a42 Mon Sep 17 00:00:00 2001 From: oneRain Date: Mon, 26 Aug 2019 16:31:17 +0800 Subject: [PATCH] =?UTF-8?q?*=20AVFileController.cs:=20fix:=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6=E7=9A=84=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * AWSUploader.cs: * QiniuUploader.cs: --- .../Storage/Internal/File/Controller/AVFileController.cs | 7 +++---- Storage/Storage/Internal/File/Controller/AWSUploader.cs | 7 +++++-- Storage/Storage/Internal/File/Controller/QiniuUploader.cs | 8 +------- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/Storage/Storage/Internal/File/Controller/AVFileController.cs b/Storage/Storage/Internal/File/Controller/AVFileController.cs index 1423890..b9fed2d 100644 --- a/Storage/Storage/Internal/File/Controller/AVFileController.cs +++ b/Storage/Storage/Internal/File/Controller/AVFileController.cs @@ -85,11 +85,10 @@ namespace LeanCloud.Storage.Internal { }); } - internal static string GetUniqueName(FileState fileState) { - string key = Random(12); - string extension = Path.GetExtension(fileState.Name); + internal static string GetUniqueName(FileState state) { + string key = Guid.NewGuid().ToString(); + string extension = Path.GetExtension(state.Name); key += extension; - fileState.CloudName = key; return key; } diff --git a/Storage/Storage/Internal/File/Controller/AWSUploader.cs b/Storage/Storage/Internal/File/Controller/AWSUploader.cs index f6b6be6..9a9413d 100644 --- a/Storage/Storage/Internal/File/Controller/AWSUploader.cs +++ b/Storage/Storage/Internal/File/Controller/AWSUploader.cs @@ -19,8 +19,11 @@ namespace LeanCloud.Storage.Internal { } internal async Task PutFile(FileState state, string uploadUrl, Stream dataStream) { - IList> makeBlockHeaders = new List>(); - makeBlockHeaders.Add(new KeyValuePair("Content-Type", state.MimeType)); + IList> makeBlockHeaders = new List> { + new KeyValuePair("Content-Type", state.MimeType), + new KeyValuePair("Cache-Control", "public, max-age=31536000"), + new KeyValuePair("Content-Length", dataStream.Length.ToString()) + }; HttpClient client = new HttpClient(); HttpRequestMessage request = new HttpRequestMessage { diff --git a/Storage/Storage/Internal/File/Controller/QiniuUploader.cs b/Storage/Storage/Internal/File/Controller/QiniuUploader.cs index a64fdee..c998daa 100644 --- a/Storage/Storage/Internal/File/Controller/QiniuUploader.cs +++ b/Storage/Storage/Internal/File/Controller/QiniuUploader.cs @@ -29,7 +29,7 @@ namespace LeanCloud.Storage.Internal { public Task Upload(FileState state, Stream dataStream, IDictionary fileToken, IProgress progress, CancellationToken cancellationToken) { state.frozenData = dataStream; - state.CloudName = GetUniqueName(state); + state.CloudName = fileToken["key"] as string; MergeFromJSON(state, fileToken); return UploadNextChunk(state, dataStream, string.Empty, 0, progress).OnSuccess(_ => { return state; @@ -101,12 +101,6 @@ namespace LeanCloud.Storage.Internal { return chunkBinary; } - internal string GetUniqueName(FileState state) { - string key = Guid.NewGuid().ToString();//file Key in Qiniu. - string extension = Path.GetExtension(state.Name); - key += extension; - return key; - } internal Task>> GetQiniuToken(FileState state, CancellationToken cancellationToken) { string str = state.Name;