Skip to content

How To: Referring to assets uploaded to my awe app

awe.media edited this page Nov 4, 2020 · 5 revisions

This gives you an overview of how you can link to or reference the different types of assets you have uploaded to the media library within your awe app.

Referring to uploaded images

Once you upload an image to your media library you can click on the (i) button to get the asset id.

get_asset_file_url()

var url = awe.util.get_asset_file_url(asset_id, file_type, url_type, fallback);
if (url) {
  // you now have a URL for this file_type related to this asset_id
} else {
  // this URL could not be constructed for some reason - see console for warnings
}

This function accepts an asset_id and optional extras and if possible it returns a valid URL you can use to access this file_type for this asset_id.

If transcoding has not been completed yet then this function will return undefined.

If the file_type requested is not available then this function will return undefined (NOTE: See the optional fallback below).

asset_id

asset_id is an integer. You can get this by clicking or tapping on the (i) icon on the thumbnail of your asset in the media library.

file_type

file_type is an optional string and the supported file types depend on the asset type.

poster_image

  • original // default fallback
  • thumbnail
  • preview
  • ld
  • sd // final fallback
  • smallest
  • largest

poster_video

  • original // default fallback
  • thumbnail
  • preview
  • default // final fallback
  • ld
  • sd
  • smallest
  • largest

panosphere_image

  • original // default fallback
  • thumbnail
  • preview
  • base (greyscale)
  • ld
  • sd // final fallback
  • hd
  • xd
  • smallest
  • largest

panosphere_video

  • original // default fallback
  • thumbnail
  • preview
  • original
  • ld
  • sd // final fallback
  • hd
  • xd
  • smallest
  • largest

model_obj

  • original
  • model // final fallback
  • material

animated_model_fbx

  • original
  • model // final fallback

sound_obj / action_sound / background_sound

  • original
  • audio // final fallback

target_image

  • original
  • thumbnail
  • default // final fallback

favicon

  • original
  • 16x16
  • 32x32 // final fallback
  • android-96x96
  • android-192x192
  • apple-57x57
  • apple-60x60
  • apple-72x72
  • apple-76x76
  • apple-114x114
  • apple-120x120
  • apple-144x144
  • apple-152x152
  • apple-180x180

url_type

If url_type is not defined or is set to cdn then you will get back a URL that points directly to the CDN, which gives you the fastest delivery.

If url_type is set to app then you get back a URL that is relative to your app host. app URLs will be redirected to the CDN URL by the app server, but are useful if you want to use a persistent URL that can be used within HTML or CSS.

However, if you use app URLs for videos and then try to use this redirected video within your 3D scene you may find iOS refuses to render this as a texture and throws a SecurityError warning. This is an iOS bug from 2012 and seems unlikely to be fixed.

fallback

fallback is an optional string that defaults to original. If it's defined and the file_type you request is not available then the fallback type of file for this asset will be returned if that is available. Otherwise it will return the final fallback for this file_type (see comments for file types above).

Please see the console warnings for various file_types as they may or may not be usable within the browser (e.g. 3D models originally uploaded as .zip files).