/// <summary> /// Computes the master key that is used to encrypt string and stream data /// in the PDF document. /// </summary> /// <param name="options"> /// The user supplied PDF options that provides access to the passwords and /// the access permissions. /// </param> /// <param name="fileId"> /// The PDF document's file identifier (see section 8.3 of PDF specification). /// </param> private void CreateMasterKey(SecurityOptions options, FileIdentifier fileId) { masterKey = ComputeEncryptionKey32( PadPassword(options.UserPassword), ownerEntry, options.Permissions, fileId.CreatedPart); }
/// <summary> /// Constructs a new standard security manager. /// </summary> /// <param name="options"> /// The user supplied PDF options that provides access to the passwords and /// the access permissions. /// </param> /// <param name="fileId"> /// The PDF document's file identifier (see section 8.3 of PDF specification). /// </param> public SecurityManager(SecurityOptions options, FileIdentifier fileId) { // note: The order that these keys are created is important. CreateOwnerEntry(options); CreateMasterKey(options, fileId); // requires the owner entry CreateUserEntry(options); // requires the master key this.permissions = options.Permissions; }
public void Init(SerializeAssetV09 serializeAsset) { AssetVersion = serializeAsset.header.Version; UnityVersion = serializeAsset.UnityVersion; ObjectInfos = new AssetObjectInfo[serializeAsset.numOfObjects]; for (int i = 0; i < serializeAsset.numOfObjects; i++) { ObjectInfos[i] = new AssetObjectInfo(); ObjectInfos[i].PathID = (ulong)serializeAsset.objectInfos[i].PathID; ObjectInfos[i].classID = serializeAsset.objectInfos[i].classID; ObjectInfos[i].typeID = serializeAsset.objectInfos[i].typeID; ObjectInfos[i].isDestroyed = serializeAsset.objectInfos[i].isDestroyed == 1; ObjectInfos[i].length = serializeAsset.objectInfos[i].length; ObjectInfos[i].data = serializeAsset.objectInfos[i].data; } ExternalFiles = new FileIdentifier[serializeAsset.numOfFileIdentifiers]; for (int i = 0; i < serializeAsset.numOfFileIdentifiers; i++) { ExternalFiles[i] = new FileIdentifier(); ExternalFiles[i].filePath = serializeAsset.fileIdentifiers[i].filePath; } }
/// <summary>获取文件二进制 /// </summary> public async Task <byte[]> GetFileAsync(FileIdentifier fileIdentifier) { var storageNode = await _fdfsClient.GetStorageNodeAsync(fileIdentifier.Patch.Name); return(await _fdfsClient.DownloadFileAsync(storageNode, fileIdentifier.FileId)); }
/// <summary>删除文件 /// </summary> public async Task DeleteFileAsync(FileIdentifier fileIdentifier) { var fastDFSPatch = (FastDFSPatch)fileIdentifier.Patch; await _fdfsClient.RemoveFileAsync(fastDFSPatch.Name, fileIdentifier.FileId); }
public async Task <IMemoryOwner <byte> > GetMemory(FileIdentifier fileId, int blockId) { var bid = new BlockIdentifier() { BlockId = (uint)blockId, FileId = (ushort)fileId.FileId, LevelId = (ushort)fileId.Level }; LinkedListNode <ProtoBlock> node; ProtoBlock block = null; var lookup = _lookup; lock (_lock) { if (lookup.TryGetValue(bid, out node)) { if (node.Value.RefCount == 0) { _lruList.Remove(node); } node.Value.RefCount++; } else { if (lookup.Count < _maxBlocks) { var offset = _currentOffset; _currentOffset += FileConsts.PageSize; block = new ProtoBlock(bid, offset); node = new LinkedListNode <ProtoBlock>(block); lookup.Add(bid, node); } else { var lastNode = _lruList.Last; if (lastNode == null) { Console.WriteLine("We ran out of space in the blockcache"); throw new NotImplementedException("We have no space at the inn, we need to figure out what we do here so we don't deadlock"); } else { lookup.Remove(lastNode.Value.BlockId); _lruList.RemoveLast(); block = new ProtoBlock(bid, lastNode.Value.Offset); node = new LinkedListNode <ProtoBlock>(block); lookup.Add(bid, node); } } } } if (block != null) { _files[fileId].ReadBlock(IntPtr.Add(_gcHandle.AddrOfPinnedObject(), block.Offset), bid); ProtoEventSource.Log.ReportCacheMiss(); } else { ProtoEventSource.Log.ReportCacheHit(); } await node.Value.Task; return(new ProtoOwner(_pinnedSlab, node.Value.Offset, this, bid)); }
public static FileModel MetaChildOfWrite(this FileModel fileModel, FileIdentifier parentIdentifier) { fileModel.Write <FileIdentifier>(MetadataKeyConstants.CHILDOF, parentIdentifier); return(fileModel); }
public string DownloadPackage(Uri url, string identifier, DateTime?updated) { if (_overwriteCache && !_requestedURLs.Contains(url)) { // Discard cached file if command line says so, // but only the first time in each run _cache.Remove(url); } _requestedURLs.Add(url); var cachedFile = _cache.GetCachedFilename(url, updated); if (!string.IsNullOrWhiteSpace(cachedFile)) { return(cachedFile); } else { var downloadedFile = Net.Download(url); string extension; switch (FileIdentifier.IdentifyFile(downloadedFile)) { case FileType.ASCII: extension = "txt"; break; case FileType.GZip: extension = "gz"; break; case FileType.Tar: extension = "tar"; break; case FileType.TarGz: extension = "tar.gz"; break; case FileType.Zip: extension = "zip"; string invalidReason; if (!NetFileCache.ZipValid(downloadedFile, out invalidReason)) { throw new Kraken($"{downloadedFile} is not a valid ZIP file: {invalidReason}"); } break; default: extension = "ckan-package"; break; } return(_cache.Store( url, downloadedFile, string.Format("netkan-{0}.{1}", identifier, extension), move: true )); } }
public ArchiveMessage(FileIdentifier identifier) { this.Identifier = identifier; }
public TextExtractMessage(FileIdentifier identifier) { this.Identifier = identifier; }
internal static JObject HTTP(JObject orig_metadata, string remote_id, NetFileCache cache, IUser user) { var metadata = orig_metadata; // Check if we should auto-inflate. string kref = (string)metadata[expand_token]; if (kref == (string)orig_metadata[expand_token] || kref == "#/ckan/http") { log.InfoFormat("Inflating from HTTP download... {0}", metadata[expand_token]); metadata["download"] = remote_id; metadata["version"] = "0.0.0"; // add a dummy version that will be replaced by the KSP-AVC parser later metadata.Remove(expand_token); var remote_uri = new Uri(remote_id); var downloaded_file = Net.Download(remote_uri); var module = CkanModule.FromJson(metadata.ToString()); // Check the type of the downloaded file. FileType downloaded_file_type = FileIdentifier.IdentifyFile(downloaded_file); if (downloaded_file_type != FileType.Zip) { // We assume the downloaded file is a zip file later on. string error_message = String.Format("Downloaded file not identified as a zip. Got {0} instead.", downloaded_file_type.ToString()); throw new Kraken(error_message); } if (metadata[version_token] != null && (metadata[version_token].ToString()).StartsWith("#/ckan/ksp-avc")) { // TODO pass the correct vref here... var versionRemote = FindVersionRemote(metadata, metadata[version_token].ToString()); metadata.Remove(version_token); try { AVC avc = AVC.FromZipFile(module, downloaded_file, versionRemote.id); avc.InflateMetadata(metadata, null, null); metadata["version"] = avc.version.ToString(); module.version = avc.version; } catch (JsonReaderException) { user.RaiseMessage("Bad embedded KSP-AVC file for {0}, halting.", module); return(null); } // If we've done this, we need to re-inflate our mod, too. module = CkanModule.FromJson(metadata.ToString()); } else { throw new Kraken("No $vref specified, $kref HTTP method requires it, bailing out.."); } ModuleInstaller.CachedOrDownload(module.identifier, module.version, module.download, cache); } else { log.WarnFormat("Not inflating metadata for {0}", orig_metadata["identifier"]); } // metadata["download"] = metadata["download"].ToString() + '#' + metadata["version"].ToString(); return(metadata); }
public ISerializedFile FindSerializedFile(FileIdentifier identifier) { return(m_files.Find(identifier.IsFile)); }
public async Task <UnknownSet> GetUnknown(FileIdentifier fileIdentifier) { return(await this.ViewSetService.LoadSet <UnknownSet>(fileIdentifier)); }
public async Task <ImageSet> GetImage(FileIdentifier fileIdentifier) { return(await this.ViewSetService.LoadSet <ImageSet>(fileIdentifier)); }
public async Task <MediaSet> GetMedia(FileIdentifier fileIdentifier) { return(await this.ViewSetService.LoadSet <MediaSet>(fileIdentifier)); }
public ISerializedFile FindSerializedFile(FileIdentifier identifier) { m_files.TryGetValue(identifier.FilePath, out SerializedFile file); return(file); }
public async Task <TextSet> GetText(FileIdentifier fileIdentifier) { return(await this.ViewSetService.LoadSet <TextSet>(fileIdentifier)); }
public override async ValueTask <IMemoryOwner <byte> > GetBlock(FileIdentifier id, int blockId) => await _lruCache.GetMemory(id, blockId);
public void WriteFile(FileIdentifier fileIdentifier, byte[] content) { EnsureValidFileIdentifier(fileIdentifier); S3FileService.WriteContentToS3(fileIdentifier, content); }
public override void RemoveFile(FileIdentifier id) { throw new NotImplementedException(); }
public MediaSource(FileIdentifier fileIdentifier, string type) { this.FileIdentifier = fileIdentifier; this.Type = type; }
public static IEnumerable <ManagerFileView> DetectFileViews(OrganizationModel organization, FileIdentifier fileIdentifier, List <AlternativeView> alternativeViews, string extension, string mimeType) { var views = new List <ManagerFileView>(); var mediaSet = MediaService.MediaSetGet(organization, fileIdentifier, alternativeViews, extension, mimeType); if (mediaSet.MediaType != MediaSet.MediaTypeEnum.Unknown) { var view = new ManagerFileView { Identifier = fileIdentifier, ViewerType = mediaSet.MediaType == MediaSet.MediaTypeEnum.Audio ? ManagerFileView.ViewerTypeEnum.Audio : mediaSet.MediaType == MediaSet.MediaTypeEnum.Video ? ManagerFileView.ViewerTypeEnum.Video : ManagerFileView.ViewerTypeEnum.Unknown, }; if (view.ViewerType == ManagerFileView.ViewerTypeEnum.Audio) { view.Icons = new[] { "audio" } } ; if (view.ViewerType == ManagerFileView.ViewerTypeEnum.Video) { view.Icons = new[] { "video" } } ; view.Label = view.ViewerType == ManagerFileView.ViewerTypeEnum.Audio ? "Audio" : "Video"; views.Add(view); var clipSet = ClipService.ClipSetGet(organization, fileIdentifier, alternativeViews, extension, mimeType); if (clipSet.MediaType != MediaSet.MediaTypeEnum.Unknown) { view = new ManagerFileView { Identifier = fileIdentifier, ViewerType = ManagerFileView.ViewerTypeEnum.Clip }; view.Icons = new[] { "fa-film" }; view.Label = "Clip Creator"; views.Add(view); } } var imageSet = ImageService.ImageSetGet(fileIdentifier, alternativeViews, extension, mimeType); if (imageSet.ImageType != ImageSet.ImageTypeEnum.Unknown) { var view = new ManagerFileView { Identifier = fileIdentifier, ViewerType = ManagerFileView.ViewerTypeEnum.Image, Icons = new[] { "image" } }; view.Label = "Image"; views.Add(view); } var documentSet = DocumentSetService.DocumentSetGet(fileIdentifier, alternativeViews, extension, mimeType); if (documentSet.DocumentType != DocumentSet.DocumentTypeEnum.Unknown) { var view = new ManagerFileView { Identifier = fileIdentifier, ViewerType = ManagerFileView.ViewerTypeEnum.Document, Icons = new[] { "file" } }; view.Label = "Document"; views.Add(view); } /* suppressed as per github #144 * var exifSet = TextService.TextSetGet(fileIdentifier, alternativeViews, extension, mimeType, "EXIF"); * if (exifSet.TextType != TextSet.TextTypeEnum.Unknown) * { * var view = new ManagerFileView * { * Identifier = exifSet.FileIdentifier, * ViewerType = ManagerFileView.ViewerTypeEnum.Text, * Icons = new[] { "fa-stethoscope" } * }; * * view.Label = "EXIF Data"; * views.Add(view); * }*/ var vttSet = TextService.TextSetGet(fileIdentifier, alternativeViews, extension, mimeType, n => n.Name == "Voicebase WebVTT"); if (vttSet.TextType != TextSet.TextTypeEnum.Unknown) { var editedVTTSet = TextService.TextSetGet(fileIdentifier, alternativeViews, extension, mimeType, n => n.Name == TranscriptService.FILENAME_VTT); /*if (editedVTTSet.TextType != TextSet.TextTypeEnum.Unknown) * views.Add(new ManagerFileView * { * Identifier = editedVTTSet.FileIdentifier, * ViewerType = ManagerFileView.ViewerTypeEnum.Text, * Icons = new[] { "fa-comments" }, * Label = "Edited Transcript" * }); * else * views.Add(new ManagerFileView * { * Identifier = vttSet.FileIdentifier, * ViewerType = ManagerFileView.ViewerTypeEnum.Text, * Icons = new[] { "fa-comments" }, * Label = "Machine Transcript" * }); */ var transcriptSet = TranscriptService.TranscriptSetGet(organization, fileIdentifier, alternativeViews, extension, mimeType); if (transcriptSet.MediaType != MediaSet.MediaTypeEnum.Unknown) { var view = new ManagerFileView { Identifier = fileIdentifier, ViewerType = ManagerFileView.ViewerTypeEnum.Transcript }; view.Icons = new[] { "fa-comments" }; view.Label = "Transcript Editor"; views.Add(view); } } var textSet = TextService.TextSetGet(fileIdentifier, alternativeViews, extension, mimeType, filter: n => n.MimeType == "text/plain" && n.Name != "EXIF" ); if (textSet.TextType != TextSet.TextTypeEnum.Unknown) { var view = new ManagerFileView { Identifier = fileIdentifier, ViewerType = ManagerFileView.ViewerTypeEnum.Text, Icons = new[] { "file" } }; view.Label = "Text"; views.Add(view); } return(views); } } }
public void Delete(FileIdentifier id) { this._fileWriter.Delete(this._fileStore.GetDataFile(id)); this._fileWriter.Delete(this._fileStore.GetMetadataFile(id)); }
public async Task <T> LoadSet <T>(FileIdentifier fileIdentifier) where T : BaseSet { var file = await api.File.GetAsync(fileIdentifier); var fileStatus = await api.File.GetOnlineStatusAsync(fileIdentifier); var organization = await api.Organization.GetAsync(fileIdentifier as OrganizationIdentifier); BaseSet set = null; // this is awful, but no clear security check to perform bool isPrivileged = !EDiscoveryUtility.IsUserEDiscovery(this.api.UserAccessIdentifiers) && !LEOUploadUtility.IsUserLeo(this.api.UserAccessIdentifiers); if (typeof(T).Equals(typeof(TextSet))) { set = TextService.TextSetGet(file, true); } if (typeof(T).Equals(typeof(DocumentSet))) { set = DocumentSetService.DocumentSetGet(file); } if (typeof(T).Equals(typeof(MediaSet))) { set = MediaService.MediaSetGet(organization, file, isPrivileged); } if (typeof(T).Equals(typeof(TranscriptSet))) { var transcriptSet = TranscriptService.TranscriptSetGet(organization, file); transcriptSet.Segments = await TranscriptService.LoadSegments(api, transcriptSet.Subtitles?.FirstOrDefault()?.FileIdentifier); set = transcriptSet; } if (typeof(T).Equals(typeof(ClipSet))) { var clipSet = ClipService.ClipSetGet(organization, file); set = clipSet; } if (typeof(T).Equals(typeof(ImageSet))) { set = ImageService.ImageSetGet(file); } if (typeof(T).Equals(typeof(UnknownSet))) { set = UnknownService.UnknownSetGet(file); } if (set.AllowedOperations == null) { set.AllowedOperations = new[] { AllowedOperation.GetAllowedOperationDownload(fileIdentifier, false) } } ; set.RootFileIdentifier = file.Read(MetadataKeyConstants.CHILDOF, defaultValue: file.Identifier); if (set.RootFileIdentifier.Equals(fileIdentifier)) { set.Views = DetectFileViews(organization, file); } else { set.Views = DetectFileViews(organization, await api.File.GetAsync(set.RootFileIdentifier)); } // some wierd logic for eDiscovery // if eDiscovery, then no subtitles if (set is MediaSet && EDiscoveryUtility.IsUserEDiscovery(api.UserAccessIdentifiers)) { var media = set as MediaSet; media.Subtitles = null; } if (fileStatus != FileModel.OnlineStatus.Online) { set.Views = new ManagerFileView[] { new ManagerFileView { ViewerType = ManagerFileView.ViewerTypeEnum.Offline, Identifier = set.RootFileIdentifier } }; set.AllowedOperations = new AllowedOperation[] { AllowedOperation.GetAllowedOperationRequestOnlineFolder(set.RootFileIdentifier) }; set.RootFileIdentifier = null; } return(set as T); }
public override void RegisterFile(string fileName, int blockCount, FileIdentifier id) { var file = new MMapBlockCacheFile(fileName, blockCount, id, this); _cache.TryAdd(id, file); }
public async Task <UnknownSet> UnknownSetGetAsync(FileIdentifier fileIdentifier) { var file = await Connection.File.GetAsync(fileIdentifier); return(UnknownSetGet(file)); }
public IActionResult Delete(FileIdentifier id) { this._uploadedFileRepository.Delete(id); return(this.RedirectToAction("Index")); }
public TranscodeMessage(FileIdentifier identifier) { this.Identifier = identifier; }
/// <summary>下载文件到指定目录 /// </summary> public async Task DownloadFileAsync(FileIdentifier fileIdentifier, string savePath) { var storageNode = await _fdfsClient.GetStorageNodeAsync(fileIdentifier.Patch.Name); _ = await _fdfsClient.DownloadFileEx(storageNode, fileIdentifier.FileId, savePath); }
public static AuditLogEntryModel ToModel(this AuditLogEntry entity) { if (entity != null) { var model = new AuditLogEntryModel { Identifier = new AuditLogEntryIdentifier { OrganizationKey = entity.OrganizationKey, AuditLogID = entity.AuditLogEntryID }, ActionType = entity.ActionType, Generated = entity.Generated, UserAgent = entity.UserAgent, InitiatorUserIdentifier = new UserIdentifier { OrganizationKey = entity.InitiatorOrganizationKey, UserKey = entity.InitiatorUserKey }, Details = entity.Details, Description = entity.Description, }; var fileIdentifier = new FileIdentifier { OrganizationKey = entity.OrganizationKey, FolderKey = entity.FolderKey, FileKey = entity.FileKey }; model.FileIdentifier = fileIdentifier.IsValid ? fileIdentifier : null; var folderIdentifier = new FolderIdentifier { OrganizationKey = entity.OrganizationKey, FolderKey = entity.FolderKey, }; model.FolderIdentifier = folderIdentifier.IsValid ? folderIdentifier : null; var organizationIdentifier = new OrganizationIdentifier { OrganizationKey = entity.OrganizationKey, }; model.OrganizationIdentifier = organizationIdentifier.IsValid ? organizationIdentifier : null; var userIdentifier = new UserIdentifier { OrganizationKey = entity.OrganizationKey, UserKey = entity.UserKey, }; model.UserIdentifier = userIdentifier.IsValid ? userIdentifier : null; return(model); } else { return(null); } }
public async Task <FileModel> ClearFileAttributesAsync([FromBody] FileIdentifier fileIdentifier) { return(await this.attributeService.ClearFileAttributesAsync(fileIdentifier)); }
/// <summary>分片上传数据 /// </summary> private async Task <FileIdentifier> MultipartUploadFile(S3Patch patch, UploadFileInfo info) { var fileId = _fileIdGenerator.GenerateFileId(StoreType.S3, patch, info); //获取S3客户端 var client = _s3ClientFactory.GetClientByBucket(patch.Bucket); //初始化分片上传 var initiateMultipartUploadResponse = await client.InitiateMultipartUploadAsync(patch.Bucket.Name, fileId); //上传Id var uploadId = initiateMultipartUploadResponse.UploadId; // 计算分片总数。 var partSize = patch.Bucket.SliceSize; //var fi = new FileInfo(spoolFile.FilePath);//? var fileSize = GetFileSize(info); var partCount = fileSize / partSize; if (fileSize % partSize != 0) { partCount++; } // 开始分片上传。partETags是保存partETag的列表,OSS收到用户提交的分片列表后,会逐一验证每个分片数据的有效性。 当所有的数据分片通过验证后,OSS会将这些分片组合成一个完整的文件。 var partETags = new List <PartETag>(); using (var fs = File.Open(info.FilePath, FileMode.Open)) { for (var i = 0; i < partCount; i++) { var skipBytes = (long)partSize * i; // 计算本次上传的片大小,最后一片为剩余的数据大小。 var size = (int)((partSize < fileSize - skipBytes) ? partSize : (fileSize - skipBytes)); byte[] buffer = new byte[size]; fs.Read(buffer, 0, size); //分片上传 var uploadPartResponse = await client.UploadPartAsync(new UploadPartRequest() { BucketName = patch.Bucket.Name, UploadId = uploadId, Key = fileId, InputStream = new MemoryStream(buffer), PartSize = size, PartNumber = i + 1 }); partETags.Add(new PartETag(uploadPartResponse.PartNumber, uploadPartResponse.ETag)); _logger.LogDebug("上传文件Key:{0},UploadId:{1},完成 {2}/{3}", fileId, uploadId, partETags.Count, partCount); } } //完成上传分片 var completeMultipartUploadResponse = await client.CompleteMultipartUploadAsync(new CompleteMultipartUploadRequest() { BucketName = patch.Bucket.Name, Key = fileId, UploadId = uploadId, PartETags = partETags }); _logger.LogDebug("分片上传完成,Key:{0},Tags:[{1}]", completeMultipartUploadResponse.Key, string.Join(",", partETags)); var fileIdentifier = new FileIdentifier() { FileId = fileId, Patch = patch, StoreType = StoreType.S3 }; return(fileIdentifier); }
public static MediaSet MediaSetGet(OrganizationModel organization, FileIdentifier fileIdentifier, List <AlternativeView> alternativeViews, string extension, string mimeType, bool isPrivileged = false) { bool noTranscodes = false; var mediaSet = new MediaSet { AutoPlay = false, Preload = true, Poster = alternativeViews?.FirstOrDefault(v => v.MimeType == MIME_PNG)?.FileIdentifier }; // query for video formats by mime-type var mp4 = alternativeViews?.FirstOrDefault(v => v.MimeType == MIME_MP4)?.FileIdentifier; var webm = alternativeViews?.FirstOrDefault(v => v.MimeType == MIME_WEBM)?.FileIdentifier; var mp3 = alternativeViews?.FirstOrDefault(v => v.MimeType == MIME_MP3)?.FileIdentifier; var exif = alternativeViews?.FirstOrDefault(v => v.Name == "EXIF")?.FileIdentifier; // check to see if the original was either of the targets if (mp4 == null && mimeType == MIME_MP4) { mp4 = fileIdentifier; } if (webm == null && mimeType == MIME_WEBM) { webm = fileIdentifier; } if (mp3 == null && mimeType == MIME_MP3) { mp3 = fileIdentifier; } var sources = new List <MediaSource>(); mediaSet.Sources = sources; if (mp4 != null) { sources.Add(new MediaSource(mp4, MIME_MP4)); } if (webm != null) { sources.Add(new MediaSource(webm, MIME_WEBM)); } if (mp3 != null) { sources.Add(new MediaSource(mp3, MIME_MP3)); } // if we don't have any of our target formats, try adding the original file if (!sources.Any()) { sources.Add(new MediaSource(fileIdentifier, mimeType)); noTranscodes = true; } var vtt = alternativeViews?.FirstOrDefault(v => v.MimeType == MIME_VTT && v.Name == TranscriptService.FILENAME_VTT)?.FileIdentifier; if (vtt == null) { vtt = alternativeViews?.FirstOrDefault(v => v.MimeType == MIME_VTT)?.FileIdentifier; } if (vtt != null) { mediaSet.Subtitles = new List <MediaSubtitles> { new MediaSubtitles { FileIdentifier = vtt, IsDefault = true, Label = "English", Language = "English" } }; } // let's see how we did mediaSet.MediaType = MediaSet.MediaTypeEnum.Unknown; if (mp3 != null) { mediaSet.MediaType = MediaSet.MediaTypeEnum.Audio; } if (mp4 != null || webm != null) { mediaSet.MediaType = MediaSet.MediaTypeEnum.Video; } // we couldn't find any alternative views, indicating a transcoder // has visited this file. let's check the primary file itself if (noTranscodes && false) { if (mimeType?.ToLower().StartsWith("video") ?? false) { mediaSet.MediaType = MediaSet.MediaTypeEnum.Video; } else if (mimeType?.ToLower().StartsWith("audio") ?? false) { mediaSet.MediaType = MediaSet.MediaTypeEnum.Audio; } } var allowedOperations = new List <AllowedOperation> { AllowedOperation.GetAllowedOperationDownload(fileIdentifier, label: "Download") }; if (mp4 != null) { allowedOperations.Add(AllowedOperation.GetAllowedOperationDownload(mp4, label: "Download MP4")); } if (exif != null) { allowedOperations.Add(AllowedOperation.GetAllowedOperationDownload(exif, label: "Download EXIF")); } if (mediaSet.MediaType == MediaSet.MediaTypeEnum.Audio && mp3 != null) { allowedOperations.Add(AllowedOperation.GetAllowedOperationDownload(mp3, label: "Download MP3")); } if (vtt != null) { allowedOperations.Add(AllowedOperation.GetAllowedOperationDownload(vtt, label: "Download Subtitles")); } else { if (isPrivileged) { if (mp3 != null && organization.Read("transcript[isActive]", defaultValue: false)) { allowedOperations.Add(AllowedOperation.GetAllowedOperationTranscribe(fileIdentifier)); } } } if (isPrivileged) { if (mp4 != null) { allowedOperations.Add(AllowedOperation.GetAllowedOperationWatermarkVideo(mp4)); } } mediaSet.AllowedOperations = allowedOperations; return(mediaSet); }
/** <summary>Updates the specified trailer.</summary> <remarks>This method has to be called just before serializing the trailer object.</remarks> */ protected void UpdateTrailer( PdfDictionary trailer, IOutputStream stream ) { // File identifier update. FileIdentifier identifier = FileIdentifier.Wrap(trailer[PdfName.ID]); if(identifier == null) {trailer[PdfName.ID] = (identifier = new FileIdentifier()).BaseObject;} identifier.Update(this); }