diff --git a/csclip/Program.cs b/csclip/Program.cs index a092753..d4c6a44 100755 --- a/csclip/Program.cs +++ b/csclip/Program.cs @@ -240,44 +240,45 @@ async Task GetDataToFileAsync(SaveDataToFileOptions options) var stdFormat = CfToStandardFormat(options.cf); - try + if (data.Contains(stdFormat)) { - if (data.Contains(stdFormat)) + if (options.store_path == null) { - if (options.store_path == null) - { - return (string)await data.GetDataAsync(stdFormat); ; - } - else + return (string)await data.GetDataAsync(stdFormat); ; + } + else + { + var blob = await data.GetDataAsync(stdFormat); + if (blob is RandomAccessStreamReference) { - var rawPayload = await data.GetDataAsync(stdFormat); - if (rawPayload is RandomAccessStreamReference) + var sblob = await (blob as RandomAccessStreamReference).OpenReadAsync(); + var ext = MimeTypes.MimeTypeMap.GetExtension(sblob.ContentType); + var fileName = $"{Guid.NewGuid().ToString()}{ext}"; + _ = Task.Run(async () => { - var fileName = Guid.NewGuid().ToString(); - _ = Task.Run(async () => + try { - var sin = await (rawPayload as RandomAccessStreamReference).OpenReadAsync(); var tempFile = await StorageFile.CreateStreamedFileAsync("temp", async (sout) => { - await RandomAccessStream.CopyAndCloseAsync(sin, sout); + await RandomAccessStream.CopyAndCloseAsync(sblob, sout); }, null); - var path = Path.GetFullPath(options.store_path); + var path = Path.GetFullPath($"{options.store_path}/"); (new FileInfo(path)).Directory.Create(); var folder = await StorageFolder.GetFolderFromPathAsync(path); - _ = tempFile.CopyAsync(folder, fileName, NameCollisionOption.ReplaceExisting); - }); + await tempFile.CopyAsync(folder, fileName, NameCollisionOption.ReplaceExisting); + } + catch { } + }); - return fileName; - } - else if (rawPayload is string) - { - return rawPayload as string; - } + return fileName; + } + else if (blob is string) + { + return blob as string; } } } - catch {} return ""; } diff --git a/csclip/csclip.csproj b/csclip/csclip.csproj index dbd3535..5f5e995 100755 --- a/csclip/csclip.csproj +++ b/csclip/csclip.csproj @@ -57,6 +57,9 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all + + 2.3.3 + 17.8.14