我正在制作一个组件,它允许我使用桌面相机的捕获制作视频。在javascript中,我有 '' vidSave.src '' 这是录制的视频的网址。当我尝试在特定对象的文件中录制视频时,视频会被录制,但是当我下载并播放它时,什么也没有出现。我想我的错误会在这里“conVer.VersionData = Blob.valueof (srcVideo);” 我不明白我错过了什么,有什么想法吗?谢谢
Javascript:
let blob = new Blob(chunks, { 'type' : 'video/mp4;' });
chunks = [];
let videoURL = window.URL.createObjectURL(blob);
vidSave.src = videoURL;
顶点:
@AuraEnabled
public static String save(String contactId, String srcVideo, string nameFile){
System.debug('saveVideo');
System.debug('contactId:: '+contactId);
System.debug('srcVideo:: '+srcVideo);
System.debug(' Blob.valueof(srcVideo): '+ Blob.valueof(srcVideo));
System.debug('nameFile:: '+nameFile);
try {
ContentVersion conVer = new ContentVersion();
conVer.ContentLocation = 'S'; // to use S specify this document is in Salesforce, to use E for external files
conVer.PathOnClient = 'Test_Image.mp4';// The files name, extension is very important here which will help the file in preview.
conVer.Title = nameFile; // Display name of the files
conVer.VersionData = Blob.valueof(srcVideo);//EncodingUtil.base64Decode(srcVideo); // converting your binary string to Blog
insert conVer; //Insert ContentVersion
System.debug('conVer: '+conVer);
// First get the Content Document Id from ContentVersion Object
Id conDoc = [SELECT ContentDocumentId FROM ContentVersion WHERE Id =:conVer.Id].ContentDocumentId;
System.debug('conDoc:: '+conDoc);
//create ContentDocumentLink record
ContentDocumentLink conDocLink = New ContentDocumentLink();
conDocLink.Visibility = 'AllUsers';
conDocLink.LinkedEntityId = contactId; // Specify RECORD ID here i.e Any Object ID (Standard Object/Custom Object)
conDocLink.ContentDocumentId = conDoc; //ContentDocumentId Id from ContentVersion
conDocLink.shareType = 'V';
insert conDocLink;
System.debug('conDocLink: '+conDocLink);
// This doesn't execute since insert causes an exception
System.debug('Statement after insert.');
return 'true';
} catch(DmlException e) {
System.debug('The following exception has occurred: ' + e.getMessage());
return String.valueOf(e.getMessage());
}
}