public ICentralizedFile GetFile(string path, string fileName) { if (!CentralizedFileStorage.IsValid(this.FileStoreKey, path, fileName)) { throw new ApplicationException("The provided path and/or file name is invalid"); } var file = this.GetAmazonS3FileStorageFileFromCache(path, fileName); if (file == null) { lock (_lockbox.GetObject(this.CreateAmazonS3FileStorageFilePrimaryKey(path, fileName).GetHashCode())) { file = this.GetAmazonS3FileStorageFileFromCache(path, fileName); if (file == null) { ObjectMetaDataResponse response = GetConnection().GetMetadata(this._bucketName, MakeKey(path, fileName), new SortedList()); if (response != null) { file = new AmazonS3FileStorageFile(this.FileStoreKey, path, fileName, (int)response.ContentLength); } if (file != null) { this.PushAmazonS3FileStorageFileToCache(file, path, fileName); } } } } return(file); }
public ICentralizedFile GetFile(string path, string fileName) { if (!CentralizedFileStorage.IsValid(this.FileStoreKey, path, fileName)) throw CreateFilePathInvalidException(path, fileName); var file = this.GetAmazonS3FileStorageFileFromCache(path, fileName); if (file == null) { lock (_lockbox.GetObject(this.CreateAmazonS3FileStorageFilePrimaryKey(path, fileName).GetHashCode())) { file = this.GetAmazonS3FileStorageFileFromCache(path, fileName); if (file == null) { ObjectMetaDataResponse metadata = GetConnection().GetMetadata(this._bucketName, MakeKey(path, fileName), new SortedList<string, string>()); if (metadata != null) file = new AmazonS3FileStorageFile(this.FileStoreKey, path, fileName, (int)metadata.ContentLength); if (file != null) this.PushAmazonS3FileStorageFileToCache(file, path, fileName); } } } return file; }