question

eswitzer07 avatar image
eswitzer07 asked

403 when uploading to AWS using Admin.GetServerBuildUploadURL

Using Admin.GetServerBuildUploadURL inside a C# tool to upload a server zip file from our build server.

The build seems to get exactly half way before throwing a 403. I cant figure out why this odd behavior is happening. Im not sure if its just not throwing the error until 50%, or if the connection is terminated at 50%.

HttpWebRequest wr = WebRequest.CreateHttp("https://F588.playfabapi.com/Admin/GetServerBuildUploadUrl");
                wr.ContentType = "application/json";
                wr.Method = "POST";
                using (var sw2 = new StreamWriter(wr.GetRequestStream()))
                {
                    var json = JsonConvert.SerializeObject(new Dictionary<string, string> { { "BuildId", buildId } });// $"{
                {\"BuildId\": \"{buildId}\"}}";
                    sw2.Write(json);
                }


                wr.Headers.Add("X-SecretKey", developerSecretKey);
                var resp = wr.GetResponse();
                using (var sr = new StreamReader(resp.GetResponseStream()))
                {
                    var responseStr = sr.ReadToEnd();
                    var respObj = JsonConvert.DeserializeObject<JObject>(responseStr);
                    string url = respObj["data"]["URL"].ToString();


                    Console.WriteLine($"Upload url received after {sw.ElapsedMilliseconds}ms:\n{url}\nUploading, please wait...");
                    sw.Restart();


                    Console.WriteLine($"Number of MiB to upload: {new FileInfo(tempZipName).Length / 1024 / 1024}");
                    var bytes = File.ReadAllBytes(tempZipName);
                    var wr2 = WebRequest.CreateHttp(url);
                    wr2.Method = "PUT";
                    wr2.ContentType = "application/zip";
                    wr2.ContentLength = bytes.Length;
                    var reqstr2 = wr2.GetRequestStream();
                    reqstr2.Write(bytes, 0, bytes.Length);
                    reqstr2.Close();
                    var resp2 = wr2.GetResponse();


                    Console.WriteLine($"Upload finished in {sw.ElapsedMilliseconds}ms! Deleting local zip file...");
                    File.Delete(tempZipName);
                    Console.WriteLine("Done!");
}

For .ContentType I've tried application/gzip, application/zip, binary/octet-stream, none seem to be doing the trick.

My PUT request looks fine, URL response from PlayFab looks to contain all the necessary information (attached screenshot). Looking through fiddler for the PUT request, it seems amazon throws back "SignatureDoesNotMatch" - but as far as I know the only signature is signed within the URL. Is additional authentication required? Am I doing something wrong here?

Also attaching fiddler's response.




playfabgameurl.png (129.7 KiB)
fiddler.png (53.5 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.

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

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.