Skip to content

Commit

Permalink
oops
Browse files Browse the repository at this point in the history
  • Loading branch information
velzie committed Feb 18, 2025
1 parent 28d8c72 commit 4613be9
Showing 1 changed file with 40 additions and 39 deletions.
79 changes: 40 additions & 39 deletions DepotDownloader/Steam3Session.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
using System.IO;
using System.Security.Cryptography;
using System.Net.Http;
using SteamKit2.Authentication;
using SteamKit2.Internal;
using System.Security.Cryptography;
using System.Net.Http.Headers;

namespace DepotDownloader
{
Expand Down Expand Up @@ -147,53 +151,50 @@ public async Task<bool> UploadSteamCloudFile(uint appid, string filename)

uint fileSize = (uint)fileData.Length;

Task.Run(async () =>
try
{
try
{
Console.WriteLine("Uploading file {0} {1}", filename, fileShaHex);
var response = await steamClient.Cloud.BeginHttpUpload(appid, filename, fileSize, fileShaHex);
using var client = new HttpClient();

var url = $"https://{response.url_host}{response.url_path}";
Console.WriteLine(url);

var content = new ByteArrayContent(fileData);
Console.WriteLine("Uploading file {0} {1}", filename, fileShaHex);
var response = await steamClient.Cloud.BeginHttpUpload(appid, filename, fileSize, fileShaHex);
using var client = new HttpClient();

content.Headers.ContentDisposition = new ContentDispositionHeaderValue("inline")
{
FileNameStar = filename,
};
content.Headers.ContentLength = fileSize;
content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
var url = $"https://{response.url_host}{response.url_path}";
Console.WriteLine(url);

HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Put, url)
{
Content = content
};
var content = new ByteArrayContent(fileData);

foreach (var header in response.request_headers)
{
if (header.name == "Content-Disposition") continue;
if (header.name == "Content-Length") continue;
if (header.name == "Content-Type") continue;
request.Headers.Add(header.name, header.value);
}
content.Headers.ContentDisposition = new ContentDispositionHeaderValue("inline")
{
FileNameStar = filename,
};
content.Headers.ContentLength = fileSize;
content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");

HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Put, url)
{
Content = content
};

HttpResponseMessage res = await client.SendAsync(request);
Console.WriteLine($"Response Status: {res.StatusCode}");
bool success = res.IsSuccessStatusCode;
await steamClient.Cloud.CommitHttpUpload(appid, filename, fileShaHex, success);
return success;
}
catch (Exception e)
foreach (var header in response.request_headers)
{
Console.WriteLine("Failed to upload file {0} {1}", filename, e);
await steamClient.Cloud.CommitHttpUpload(appid, filename, fileShaHex, false);
return false;
if (header.name == "Content-Disposition") continue;
if (header.name == "Content-Length") continue;
if (header.name == "Content-Type") continue;
request.Headers.Add(header.name, header.value);
}
});


HttpResponseMessage res = await client.SendAsync(request);
Console.WriteLine($"Response Status: {res.StatusCode}");
bool success = res.IsSuccessStatusCode;
await steamClient.Cloud.CommitHttpUpload(appid, filename, fileShaHex, success);
return success;
}
catch (Exception e)
{
Console.WriteLine("Failed to upload file {0} {1}", filename, e);
await steamClient.Cloud.CommitHttpUpload(appid, filename, fileShaHex, false);
return false;
}

}

Expand Down

0 comments on commit 4613be9

Please sign in to comment.