ChatiumFor developersPlaygroundPricing
Sign in

Class StorageAudioFile

An object-oriented representation of an audio file in storage.

Example usage

import {StorageAudioFile} from '@app/storage'
import {jsx} from '@app/html-jsx'

app.html('/', () => {
  const hash = 'audio_VqZCXcG4NC.d39.mpga'
  const file = new StorageAudioFile(hash)
  return <html><body>
    <p>File {file.hash}</p>
    <p>Type: {file.type}</p>
    {file.durationMaybe && <p>
      Duration: {
        Math.floor(file.duration / 60 / 60)
      }:{
        Math.floor((file.duration / 60) % 60).toString().padStart(2, '0')
      }:{
        (file.duration % 60).toString().padStart(2, '0')
      }
    </p>}
    <p><a href={file.downloadUrl}>Download</a></p>
  </body></html>
})

Properties:

  • hash - the hash of the file.
  • type - the type of the file. Can be: file, image, video, audio
  • downloadUrl - URL for downloading the file. The file will be served with an HTTP header forcing the download instead of opening it in the browser window. There is no need to open the file in a new tab.
  • duration - the duration of the audio file in seconds. If unknown, it will throw an exception.
  • durationMaybe - the duration of the audio file in seconds. If unknown, it will return undefined.