Facing issue with retrieving image on Salesforce Community page,
I had tried the same community image url on chrome, ie and mozilla browser.
But, this will work fine on LWC component when i am posting it on app page then image is displaying properly. ie image preview work fine on the app page but not on the community view.
Я также пытался указать собственный URL-адрес, но проблема осталась прежней. Когда я щелкнул правой кнопкой мыши по маленькому значку изображения, отображаемому в сообществе, скопировал URL-адрес изображения и разместил его в браузере, тогда он показывал мне ошибку, представленную в виде прикрепленного к этому сообщению снимка экрана.
For more detail description on inspect element it was giving : error code - 503
---- .cls code ----
@AuraEnabled(cacheable=true)
public static List<ContentDocument> retriveFiles(String ticketId)
{
system.debug('ticketId line 10 ' + ticketId);
List<ContentDocumentLink> listContentDocumentLink = [SELECT
ContentDocumentId FROM ContentDocumentLink WHERE LinkedEntityId =:ticketId
LIMIT 1];
if (!listContentDocumentLink.isEmpty()){
List<ContentDocument> listContentDocument = [SELECT Id, Title,
FileType, FileExtension FROM ContentDocument WHERE Id
=:listContentDocumentLink[0].ContentDocumentId];
if(!listContentDocument.isEmpty()){
system.debug(' listContentDocument[0] ' +
listContentDocument[0]);
return listContentDocument;
}
}
return null;
}
@AuraEnabled
public static List<FileData> GetEntityRecordFiles(string ticketId)
{
system.debug('BASE_URL line 10 ' + BASE_URL);
system.debug('ticketId line 10 ' + ticketId);
List<ContentDocumentLink> links=[SELECT ContentDocumentId,LinkedEntityId
FROM ContentDocumentLink where LinkedEntityId=:ticketId];
Set<Id> ids=new Set<Id>();
for(ContentDocumentLink link:links)
{
ids.add(link.ContentDocumentId);
}
List<ContentVersion> versions=[SELECT
VersionData,Title,ContentDocumentId,FileExtension FROM ContentVersion WHERE
ContentDocumentId = :ids AND IsLatest = true];
List<FileData> files=new List<FileData>();
for(ContentVersion attach:versions)
{
FileData data=new FileData();
if(versions!=null && versions.size()>0)
{
data.Content =
EncodingUtil.base64Encode(versions[0].VersionData);
data.ContentType = ContentType(versions[0].FileExtension);
}
data.DownloadUrl =
'/sfc/servlet.shepherd/document/download/'+versions[0].ContentDocumentId;
data.FileUrl = '/sfc/servlet.shepherd/version/renditionDownload?
rendition=THUMB720BY480&versionId='+versions[0].Id;
this.relatedImageData.push({ Id: img.Id, url:
'/sfc/servlet.shepherd/version/download/' + versions[0].Id});
files.add(data);
}
return files;
}
--CODE IN .html File------
<template for:each={files} for:item="keyValue" >
<tr key={keyValue.Id}>
<template if:true={keyValue.DownloadUrl}>
<img src={keyValue.DownloadUrl}/>
</template>
</tr>
</template>
--CODE IN .js File -----
filePreview(event) {
// Naviagation Service to the show preview
this[NavigationMixin.Navigate]({
type: 'standard__namedPage',
attributes: {
pageName: 'filePreview'
},
state : {
// assigning ContentDocumentId to show the preview of file
selectedRecordId: event.currentTarget.dataset.id
}
})
}
[ ! [сообщенная ошибка] [1]] [1]
[1]: https://i.stack.imgur.com/WOjSv.png