public void UploadMedias(IPublishTweetParameters parameters) { _uploadQueryExecutor.UploadMedias(parameters.Medias, false); if (parameters.Medias.Any(x => !x.HasBeenUploaded)) { throw new OperationCanceledException("The tweet cannot be published as some of the medias could not be published!"); } else { parameters.MediaIds.AddRange(parameters.Medias.Select(x => x.UploadedMediaInfo.MediaId)); } var binariesMedia = _uploadQueryExecutor.UploadBinaries(parameters.MediaBinaries); if (binariesMedia.Any(x => !x.HasBeenUploaded)) { throw new OperationCanceledException("The tweet cannot be published as some of the binaries could not be published!"); } else { parameters.MediaIds.AddRange(binariesMedia.Select(x => x.UploadedMediaInfo.MediaId)); } }
/// <summary> /// Create and Upload multiple medias on upload.twitter.com /// </summary> public static IEnumerable <IMedia> UploadBinaries(IEnumerable <byte[]> binaries) { return(_uploadQueryExecutor.UploadBinaries(binaries)); }