Private Files

Private files are protected against public access. This means you can't access them using their file descriptor's url property.

You may want to make a file private if it's for sale or contains personal information.

File descriptors for private files still include a top-level thumbnailUrl property. For images and videos this is based on the file's contents. For other media types, it contains an icon representing the file type.

Make your file private

You can make a file private by setting its private property to true when you add it to a site using one of the following methods:

Note: Making a file private impacts the following file descriptor properties:

  • yourFile.url: Has a URL value, but it returns a 403 (unauthorized) response, meaning it won't work.
  • One of the following media URLs has a value of an empty string, depending on the type of file:
    • Video: yourFile.media.video.resolutions.url
    • Audio: yourFile.media.audio.assets[X].url
    • Document: yourFile.media.document.url
    • Archive: yourFile.media.archive.url
    • Image: yourFile.media.image.image.url

Access a private file

Use the generateFileDownloadUrl() method to access a private file. Call the method with your private file's ID. This will return a new URL that you can use to download the file.

Did this help?