public void Test() { /* var x = "woof/bubu/x"; var dir = new S3DirectoryInfo(_client, _amazonS3StorageConfiguration.AWSFileBucket, "a/b"); dir.Create(); Console.WriteLine("Name: " + dir.Name + ", FullName: " + dir.FullName); var dir2 = new S3DirectoryInfo(_client, _amazonS3StorageConfiguration.AWSFileBucket, "1\\2"); dir2.Create(); Console.WriteLine("Name: " + dir2.Name + ", FullName: " + dir2.FullName); var file = new S3FileInfo(_client, _amazonS3StorageConfiguration.AWSFileBucket, "1\\2\\t.txt"); using (file.Create()) { } Console.WriteLine("Name: {0}, FullName: {1}, DirName: {2}", file.Name, file.FullName, file.DirectoryName); var file2 = new S3FileInfo(_client, _amazonS3StorageConfiguration.AWSFileBucket, "a/b/t2.txt"); using (file2.Create()) { } Console.WriteLine("Name: {0}, FullName: {1}, DirName: {2}", file2.Name, file2.FullName, file2.DirectoryName); =*/ using (var fsFileStream = File.OpenRead(@"E:\al\pics\adventure_time\x.jpg")) { var a3File = new S3FileInfo(_client, _amazonS3StorageConfiguration.AWSFileBucket, @"test\x2.jpg"); using (a3File.Create()) { } using(var outStream = a3File.OpenWrite()) { fsFileStream.CopyTo(outStream); } PublishFile(a3File.FullName); } }
public void SaveStream(string path, Stream inputStream) { path = CleanPath(path); var file = new S3FileInfo(_client, _amazonS3StorageConfiguration.AWSFileBucket, path); var isNew = !file.Exists; using (var stream = file.Exists ? file.OpenWrite() : file.Create()) { inputStream.CopyTo(stream); } if (isNew) { PublishFile(path); } }