public async Task CreateFileFromStreamAsync(string path, Stream inputStream, bool overwrite = false) { if (!overwrite && await _ftpClient.FileExistsAsync(path)) { throw new FileStoreException($"Cannot create file '{path}' because it already exists."); } if (await _ftpClient.DirectoryExistsAsync(path)) { throw new FileStoreException($"Cannot create file '{path}' because it already exists as a directory."); } // Create directory path if it doesn't exist. var physicalDirectoryPath = Path.GetDirectoryName(path); await _ftpClient.CreateDirectoryAsync(physicalDirectoryPath); await _ftpClient.UploadAsync(inputStream, path); //using (var outputStream = _ftpClient.OpenWrite(path)) //{ // await inputStream.CopyToAsync(outputStream); // outputStream.Close(); //} }
public override async Task UploadFileAsync(string path, byte[] content, CancellationToken ctk = default) { await _client.UploadAsync(content, path, token : ctk); }