Hi there, I am trying to build a relatively simple DLC content system with PlayFab. I have a problem with the downloaded file, however, getting error "Error while downloading Asset Bundle: Failed to decompress data for the AssetBundle".
After debugging it looks like the logic is getting the URL correctly, the downloading itself is successful and in the request object, there is seemingly the correct amount of bytes received. The moment I get to the point of retrieving the assetBundle object I get the error above and the bundle itself is null.
Interestingly enough, if I use the URL provided by the PlayFab API in a browser, the file I download is successfully loaded via AssetBundle.LoadFromFileAsync test call. So, the binary format seems to be intact.
I am not sure what I am missing at this point. Any help or suggestion will be much appreciated. Here is the simple code I am using to download the bundle:
public void RetrieveAssetBundle( string dlcPath, string dlcName, string dlcHash, OnAssetBundleRetrieved onAssetBundleRetrieved ) { this.onAssetBundleRetrieved = onAssetBundleRetrieved; PlayFabClientAPI.GetContentDownloadUrl( new GetContentDownloadUrlRequest() { Key = dlcPath + dlcName, ThruCDN = false // TODO: set this to true in production }, ( GetContentDownloadUrlResult result ) => StartCoroutine( DownloadFromCDN( result.URL, dlcName, dlcHash ) ), ( PlayFabError error ) => Debug.LogError( "RetrieveAssetBundle Error: " + error.ErrorMessage ) ); } private IEnumerator DownloadFromCDN( string cdnDownloadURL, string dlcName, string dlcHash ) { Debug.Log( "PlayFab download URL: " + cdnDownloadURL ); using ( UnityWebRequest request = UnityWebRequest.GetAssetBundle( cdnDownloadURL, new CachedAssetBundle() { hash = Hash128.Parse( dlcHash ), name = downloadedAssetBundlesPath + dlcName }, 0 ) ) { yield return request.SendWebRequest(); if ( request.isNetworkError || request.isHttpError ) { Debug.LogError( "DownloadFromCDN Error: " + request.error ); } else { AssetBundle bundle = DownloadHandlerAssetBundle.GetContent( request ); if ( onAssetBundleRetrieved != null ) { onAssetBundleRetrieved( bundle ); } } } }