Assets

Methods

canWriteCacheValue(url) → {boolean}
Parameters:
Name Type Description
url string
Returns:
Type: boolean
compressData(options, scope, callbackopt)
Parameters:
Name Type Attributes Default Description
options
scope
callback <optional>
""
decompressData(options, scope, callbackopt)
Parameters:
Name Type Attributes Default Description
options
scope
callback <optional>
""
deleteAsset(options, scope, callbackopt)
Parameters:
Name Type Attributes Default Description
options
scope
callback <optional>
""
downloadData(url, callback)
Download data from the connected domain's asset server.
Parameters:
Name Type Description
url string URL of asset to download, must be ATP scheme URL.
callback Assets~downloadDataCallback
extractAssetHash(input) → {string}
Parameters:
Name Type Description
input string
Returns:
Type: string
getAsset(options, scope, callbackopt)
Request Asset data from the ATP Server
Parameters:
Name Type Attributes Description
options URL | Assets.GetOptions An atp: style URL, hash, or relative mapped path; or an Assets.GetOptions object with request parameters
scope Assets~getAssetCallback A scope callback function to receive (error, results) values
callback function <optional>
getATPUrl(input) → {string}
Parameters:
Name Type Description
input string
Returns:
Type: string
getCacheStatus(scope, callbackopt)
Parameters:
Name Type Attributes Description
scope
callback <optional>
getMapping(path, callback)
Look up a path to hash mapping within the connected domain's asset server
Parameters:
Name Type Description
path string
callback Assets~getMappingCallback
hashData(data) → {object}
Parameters:
Name Type Description
data
Returns:
Type: object
hashDataHex(data) → {string}
Parameters:
Name Type Description
data
Returns:
Type: string
initializeCache() → {boolean}
Returns:
Type: boolean
isValidFilePath(input) → {boolean}
Parameters:
Name Type Description
input string
Returns:
Type: boolean
isValidHash(input) → {boolean}
Parameters:
Name Type Description
input string
Returns:
Type: boolean
isValidPath(input) → {boolean}
Parameters:
Name Type Description
input string
Returns:
Type: boolean
loadFromCache(options, scope, callbackopt)
Parameters:
Name Type Attributes Description
options
scope
callback <optional>
putAsset(options, scope[callback, callbackopt)
Upload Asset data to the ATP Server
Parameters:
Name Type Attributes Description
options Assets.PutOptions A PutOptions object with upload parameters
scope[callback Assets~putAssetCallback A scoped callback function invoked with (error, results)
callback function <optional>
queryCacheMeta(options, scope, callbackopt)
Parameters:
Name Type Attributes Description
options
scope
callback <optional>
resolveAsset(options, scope, callbackopt)
Parameters:
Name Type Attributes Default Description
options
scope
callback <optional>
""
saveToCache(options, scope, callbackopt)
Parameters:
Name Type Attributes Description
options
scope
callback <optional>
saveToCache(url, data, metadata, scope, callbackopt)
Parameters:
Name Type Attributes Description
url
data
metadata
scope
callback <optional>
setBakingEnabled(path, enabled, callback)
Parameters:
Name Type Description
path string
enabled boolean
callback
setMapping(path, hash, callback)
Sets up a path to hash mapping within the connected domain's asset server
Parameters:
Name Type Description
path string
hash string
callback Assets~setMappingCallback
uploadData(data, callback)
Upload content to the connected domain's asset server.
Parameters:
Name Type Description
data string content to upload
callback Assets~uploadDataCallback called when upload is complete

Type Definitions

GetOptions
A set of properties that can be passed to Assets.getAsset.
Type: object
Properties:
Name Type Attributes Default Description
url string <optional>
an "atp:" style URL, hash, or relative mapped path to fetch
responseType string <optional>
text the desired reponse type (text | arraybuffer | json)
decompress boolean <optional>
false whether to attempt gunzip decompression on the fetched data See: Assets.putAsset and its .compress=true option
PutOptions
A set of properties that can be passed to Assets.putAsset.
Type: object
Properties:
Name Type Attributes Default Description
data ArrayBuffer | string <optional>
byte buffer or string value representing the new asset's content
path string <optional>
null ATP path mapping to automatically create (upon successful upload to hash)
compress boolean <optional>
false whether to gzip compress data before uploading
downloadDataCallback(data)
Called when downloadData is complete
Parameters:
Name Type Description
data string content that was downloaded
getAssetCallback(error, result)
Called when Assets.getAsset is complete.
Parameters:
Name Type Description
error string contains error message or null value if no error occured fetching the asset
result Asset~getAssetResult result object containing, on success containing asset metadata and contents
getAssetResult
Result value returned by Assets.getAsset.
Type: object
Properties:
Name Type Attributes Description
url string <optional>
the resolved "atp:" style URL for the fetched asset
hash string <optional>
the resolved hash for the fetched asset
response string | ArrayBuffer | Object <optional>
response data (possibly converted per .responseType value)
responseType string <optional>
response type (text | arraybuffer | json)
contentType string <optional>
detected asset mime-type (autodetected)
byteLength number <optional>
response data size in bytes
decompressed number <optional>
flag indicating whether data was decompressed
getMappingCallback(assetID, error)
Called when getMapping is complete.
Parameters:
Name Type Description
assetID string hash value if found, else an empty string
error string error description if the path could not be resolved; otherwise a null value.
putAssetResult
Result value returned by Assets.putAsset.
Type: object
Properties:
Name Type Attributes Description
url string <optional>
the resolved "atp:" style URL for the uploaded asset (based on .path if specified, otherwise on the resulting ATP hash)
path string <optional>
the uploaded asset's resulting ATP path (or undefined if no path mapping was assigned)
hash string <optional>
the uploaded asset's resulting ATP hash
compressed boolean <optional>
flag indicating whether the data was compressed before upload
byteLength number <optional>
flag indicating final byte size of the data uploaded to the ATP server
puttAssetCallback(error, result)
Called when Assets.putAsset is complete.
Parameters:
Name Type Description
error string contains error message (or null value if no error occured while uploading/mapping the new asset)
result Asset~putAssetResult result object containing error or result status of asset upload
setBakingEnabledCallback()
Called when setBakingEnabled is complete.
setMappingCallback(error)
Called when setMapping is complete
Parameters:
Name Type Description
error string
uploadDataCallback(url, hash)
Called when uploadData is complete
Parameters:
Name Type Description
url string
hash string