public Task <bool> Exists(string fileName, DirectoryEnum directoryEnum = DirectoryEnum.Published) { _traceManager.TraceInfo($"Test if file exists : {GetFilePath(fileName, directoryEnum)}"); try { Connect(); return(Task.FromResult(_sftpClient.Exists(GetFilePath(fileName, directoryEnum)))); } catch { return(Task.FromResult(false)); } }
public String Save(DirectoryEnum denum, String localFilename) { String directory = getDirectory(denum); if (_storageMode == StorageMode.S3) { PutObjectRequest request = new PutObjectRequest(); request.WithBucketName("FaceSpace"); String s3path = directory + _directorySeparator + Path.GetFileName(localFilename); request.WithKey(s3path); request.WithFilePath(localFilename); request.AutoCloseStream = true; request.CannedACL = S3CannedACL.PublicRead; AmazonS3 client = Amazon.AWSClientFactory.CreateAmazonS3Client(_accessKey, _secretKey, RegionEndpoint.USEast1); //var client = Amazon.AWSClientFactory.CreateAmazonS3Client(RegionEndpoint.USEast1); using (S3Response r = client.PutObject(request)) { } return "https://s3.amazonaws.com/FaceSpace/" + s3path; } else { String dest = _localPath + "\\" + directory + _directorySeparator + Path.GetFileName(localFilename); System.IO.File.Copy(localFilename, dest, true); return _virtualDirectory + "\\" + directory + _directorySeparator + Path.GetFileName(localFilename); } }
String getDirectory(DirectoryEnum dir) { return dir == DirectoryEnum.Faces ? "Faces" : "TempFaces"; }