1

Using a Lightning Component in a Customer Community, Im displaying a file directly after the user uploads it:

<img src="{!'/sfc/servlet.shepherd/version/renditionDownload?rendition=THUMB720BY480&amp;versionId='+ v.attachment.LatestPublishedVersionId }"  />

The issue is, some file previews arent immediately available, as they need to be generated. This is mainly an issue with non-image type files (pdf/word/excel/etc).

This doesnt throw the usual 404 error, or any error it seems. It just show the broken link image.

Salesforce seems to have a File Preview Status for previews:

The availability status of the preview. Values are:

  • Available—Preview is available.
  • InProgress—Preview is being processed.
  • NotAvailable—Preview is unavailable.
  • NotScheduled—Generation of the preview isn’t scheduled yet.

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_connectapi_output_file_preview.htm

(similar documentation in the Chatter Rest API docs)

Is there a fairly simple way in Apex, or directly in the Lightning Component, to get this Status?

0

1 Answer 1

0

You can probably just do a query in SOQL on the status if you have the latest version ID?

I believe otherwise another solution could be to use the onerror attribute on tags and execute javascript to handle it:

<img src="imagenotfound.gif" alt="Image not found" onerror="this.src='imagefound.gif';" />

(Or was that what you meant by "does not throw the usual 404" ?)

1
  • 1
    Correct about the error - I have used onerror before with images, and this preview does not seem to throw an error as you may expect for a broken/missing link. Im guessing because it is a valid location, just not available yet. /// As far as a SOQL query - Ive gone through Content Document API docs and Workbench queries, I couldnt find the Preview Status. Maybe I overlooked it
    – ATA1k
    Jun 6, 2017 at 17:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .