I have an option to Upload the document in the community Portal.
<lightning-input type="file" onchange={handleFileChange} name="uploadFile" multiple label="Attachment">
</lightning-input>
@api
async handleFileChange(event) {
this.attachmentArray = await Promise.all(
[...event.target.files].map(file => this.readFile(file))
);
console.log("attachmentArray -->" + JSON.stringify(this.attachmentArray));
var myJSON = JSON.stringify(this.attachmentArray);
console.log("myJSON -->" + myJSON);
addAttachment({
timebillingId: this.timesheetBillingId,
strBase64: myJSON,
loggedinUserId: this.recordId,
}).then((result) => {
........
........
Apex Class
ContentVersion cv = new ContentVersion();
cv.VersionData = EncodingUtil.base64Decode(w.base64);
cv.Title = documentName;
cv.PathOnClient = documentName;
cverList.add(cv);
insert cverList;
list<contentversion> cvlist;
if(
contentversion.SObjectType.getDescribe().isAccessible()){
cvlist = [select id, contentdocumentid, Title from contentversion where Id IN:cverList];
}
Note: From this point i can able to get the content document Id.
Attached document are Listing in the data table and On clicking of the attached document i need to preview the attachment.
Trying to frame the Content document as below
String fullFileURL = URL.getSalesforceBaseUrl().toExternalForm();
fullFileURL = fullFileURL + '/lightning/r/ContentDocument/'+ cdt.ContentDocumentId +'/view';
The above URL is redirecting to below Page, Can anyone help Anything I am missing here.
Thanks for the help