question

YuKim avatar image
YuKim asked

CDN upload is not work

Download content is working but upload content is not working

I upload file name "25.bin"

first upload is work activate

but download that does not work

website is not displayed "25.bin".

"Bin2.bin" is uploaded with UPLOADFILES Button in website

Bin2.bin is no probelm to downlaod

why this error occur?

unity3dContent
11111111.png (8.5 KiB)
111112.png (8.0 KiB)
1 comment
10 |1200

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

YuKim avatar image YuKim commented ·
    void LaterStart()
    {
        string Keyname = "25.bin";
      UploadFileToCDN(Keyname);
    }

    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")
    {
        WWWForm form = new WWWForm();
        form.AddBinaryData("Data", content);


        UnityWebRequest www = UnityWebRequest.Post(presignedUrl, form);
        if (www.isNetworkError || www.isHttpError)
        {
            Debug.Log(www.error);
        }
        else
        {
            Debug.Log("Form upload complete!");
        }


    }

0 Likes 0 ·

1 Answer

·
Hernando avatar image
Hernando answered

I noticed that you use POST method to update data in your code. Actually, we provide very detailed tutorial about CDN: https://api.playfab.com/docs/tutorials/landing-content/cdn and it has mentioned that you must make HTTP PUT request to update data.

So we recommend editing your code base on this then trying to upload your data. If this problem still occurs in your latest test, network tools such as Wireshark can help you to check if there is any SSL connection issue between PlayFab server and you.

10 |1200

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

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.