我创建了一个创建到MemoryStream的iTextSharp PDF文件。但是我现在需要将这个文件传递给Kentico媒体库。Kentico - 将MemoryStream文件传递给MediaFileInfo API
如果有人能告诉我如何做到这一点,我将不胜感激。我目前的代码是:
//Media Library Info - takes Media Library Name and Website Name
MediaLibraryInfo libraryInfo = MediaLibraryInfoProvider.GetMediaLibraryInfo("MyLibrary", CMSContext.CurrentSiteName);
//Folder in Media Library where Item will be Inserted
string mediaLibraryFolder = folder;
//create media file info item - takes the relative path to the document, the library ID, and the folder name where the document will be located within the media library
MediaFileInfo fileInfo = new MediaFileInfo();
fileInfo.FileLibraryID = libraryInfo.LibraryID;
fileInfo.FileBinaryStream = file;
fileInfo.FileName = title.Replace(" ", "").Trim();
fileInfo.FileTitle = title;
fileInfo.FileDescription = description;
fileInfo.FileExtension = ".pdf";
fileInfo.FileMimeType = "application/pdf";
fileInfo.FilePath = String.Concat("/", folder, "/", title.Replace(" ", "").Trim(), ".pdf");
// Save media file info
MediaFileInfoProvider.ImportMediaFileInfo(fileInfo);
我一直收到由于可空列为例的数据库错误, FileSize,FileExtension等。由于我正在使用MemoryStream,因此无法找到提供所有信息的方法。
我是否将MediaFileInfo API错误地与MemoryStream文件结合使用?
我明白这是有道理的。谢谢约翰! – R100
没问题!很高兴我能帮上忙。随时upvote,如果你想:D –
Upvote完成! :-) – R100