question

YuKim avatar image
YuKim asked

I make project mesh upload Donwload project and error is occured upload download

I make project mesh upload Donwload project and error is occured upload download

uploading succesfully but i don't know downloading

I convet mesh to binary file and upload

I download binary file and convert binary to mesh

2 error

1.I uploaded file but website Gamemanger/content/filemangement is not displayed

2. I download file but I do not know whether it is the correct file or not

i think that is not correct file

the reason is MeshSerializer doesn't work

MeshSerailizer worked fine without upload,download

This is upload cord

public void UploadFileToCDN
(string key, byte[] content, string contentType = "binary/octet-stream")
    {
        GetUploadUrl(key, contentType, presignedUrl =>
        {
            PutFile(presignedUrl, content, contentType);
        });
    }


    void GetUploadUrl(string key, string contentType, Action<string> onComplete)
    {
        PlayFabAdminAPI.GetContentUploadUrl(new GetContentUploadUrlRequest()
        {
            ContentType = contentType,
            Key = key
        }, result => onComplete(result.URL),
        error => Debug.LogError(error.GenerateErrorReport()));
    }
 void PutFile(string presignedUrl, byte[] content, string contentType = "binary/octet-stream")
    {
        List<IMultipartFormSection> formData = new List<IMultipartFormSection>();
        formData.Add(new MultipartFormDataSection("field1=foo&field2=bar"));
        formData.Add(new MultipartFormFileSection(content));

        UnityWebRequest www = UnityWebRequest.Post(presignedUrl, formData);


        if (www.isNetworkError || www.isHttpError)
        {
            Debug.Log(www.error);
        }
        else
        {
            Debug.Log("Form upload complete!");
        }
    }

this is cord Download cord

 public void DownloadFileFromCDN(string key)
    {

        GetDownloadUrl(key, presignedUrl =>
        {
          MeshSerializer.DeserializeMesh(GetFile(presignedUrl), GetComponent<MeshFilter>().mesh);
        });
    }


    void GetDownloadUrl(string key, Action<string> onComplete)
    {
        PlayFabClientAPI.GetContentDownloadUrl(new GetContentDownloadUrlRequest()
        {
            Key = key,
            ThruCDN = true
        }, result => onComplete(result.URL),
        error => Debug.LogError(error.GenerateErrorReport()));
    }


    byte[] GetFile(string preauthorizedUrl)
    {
        UnityWebRequest www = UnityWebRequest.Get(preauthorizedUrl);
        // yield return www.SendWebRequest();


        if (www.isNetworkError || www.isHttpError)
        {
            Debug.Log(www.error);
            return null;
        }
        else
        {
           byte[] results = www.downloadHandler.data;
            return results;
        }
        
    }


unity3dContent
2211.png (9.7 KiB)
6 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Seth Du avatar image Seth Du ♦ commented ·

Have you called API FinalizeFileUploads after the upload? https://docs.microsoft.com/en-us/rest/api/playfab/data/file/finalizefileuploads?view=playfab-rest

According to the Documentation: after using the upload calls FinalizeFileUploads must be called to move the file status from pending to live.

0 Likes 0 ·
YuKim avatar image YuKim Seth Du ♦ commented ·

Thank you for asking

use FinalizeFileUploads error is occured .

how to solve this error?

english is very hard language

i really appreciate you responding even if I write English strangely.

this is error part

PlayFabAuthenticationAPI.GetEntityToken(new GetEntityTokenRequest(),(entityResult) =>
        {
            entityId = entityResult.Entity.Id;


            Debug.Log(entityResult.Entity.Id);
            entityType = entityResult.Entity.Type;
            PlayFab.DataModels.FinalizeFileUploadsRequest finalizeFileUploadsRequest = new PlayFab.DataModels.FinalizeFileUploadsRequest
            {
                Entity = new PlayFab.DataModels.EntityKey { Id = entityId, Type = entityType },
                FileNames = Keyname
            };


            PlayFabDataAPI.FinalizeFileUploads(finalizeFileUploadsRequest, OnUploadSuccess, OnSharedFailure);


        }, OnPlayFabError);

0 Likes 0 ·
1111.png (22.5 KiB)
Seth Du avatar image Seth Du ♦ YuKim commented ·

Can you print out the "entityType"?

0 Likes 0 ·
Show more comments

0 Answers

·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.