private void Publish(IS3Client client, IEnumerable <ITaskItem> sourceFiles, string bucket, string destinationFolder, bool publicRead, int timeoutMilliseconds, String uploadIfNotExists = null) { if (uploadIfNotExists != null) { uploadIfNotExists = uploadIfNotExists.Replace(".", "\\.").Replace("*", ".*"); } foreach (var fileItem in sourceFiles.Where(taskItem => taskItem != null && !string.IsNullOrEmpty(taskItem.GetMetadata("Identity")))) { var info = new FileInfo(fileItem.GetMetadata("Identity")); var headers = MsBuildHelpers.GetCustomItemMetadata(fileItem); Logger.LogMessage(MessageImportance.Normal, string.Format("Copying file {0}", info.FullName)); if (uploadIfNotExists != null && Regex.IsMatch(info.Name, uploadIfNotExists)) { if (!client.FileExists(bucket, CreateRelativePath(destinationFolder, info.Name))) { client.PutFile(bucket, CreateRelativePath(destinationFolder, info.Name), info.FullName, headers, publicRead, timeoutMilliseconds); } } else { client.PutFile(bucket, CreateRelativePath(destinationFolder, info.Name), info.FullName, headers, publicRead, timeoutMilliseconds); } } }
public override bool Execute(CancellationToken cancellationToken) { return(_client.FileExists(_bucketName, _fileName)); }