コード例 #1
0
    /// <summary>
    /// Requests a remote endpoint for uploads from the PlaFab service.
    /// </summary>
    void GetContentUploadURL(AssetBundleHelperObject asset)
    {
        var request = new GetContentUploadUrlRequest();

        if (asset.BundlePlatform == AssetBundleHelperObject.BundleTypes.Android)
        {
            request.Key = "Android/" + asset.ContentKey;        // folder location & file name to use on the remote server
        }
        else if (asset.BundlePlatform == AssetBundleHelperObject.BundleTypes.iOS)
        {
            request.Key = "iOS/" + asset.ContentKey;
        }
        else // stand-alone
        {
            request.Key = asset.ContentKey;
        }
        request.ContentType = asset.MimeType;       // mime type to match the file

#if UNITY_WEBPLAYER
        //UnityEngine.Deubg.Log("Webplayer does not support uploading files.");
#else
        PlayFabAdminAPI.GetContentUploadUrl(request, result =>
        {
            asset.PutUrl = result.URL;

            byte[] fileContents = File.ReadAllBytes(asset.LocalPutPath);
            PutFile(asset, fileContents);
        }, OnPlayFabError);
#endif
    }
コード例 #2
0
        void GetUploadUrl(string key, string contentType, Action <string> onComplete)
        {
            Debug.Log("GetUploadUrl");
            PlayFabAdminAPI.GetContentUploadUrl(new GetContentUploadUrlRequest()
            {
                ContentType = contentType,
                Key         = key
            }, result => onComplete(result.URL),

                                                error =>
            {
                string errorInfo = error.GenerateErrorReport();
                Debug.LogError(errorInfo);
            });
        }