Skip to content

Commit

Permalink
- Fix GoFileIo file uploading
Browse files Browse the repository at this point in the history
  • Loading branch information
KoalaBear84 committed Aug 5, 2024
1 parent 8121d45 commit 586a49f
Showing 1 changed file with 212 additions and 19 deletions.
231 changes: 212 additions & 19 deletions src/OpenDirectoryDownloader/FileUpload/GoFileIo.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using OpenDirectoryDownloader.Models;
using System.Net.Http.Headers;
using System.Net.Http.Json;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace OpenDirectoryDownloader.FileUpload;

Expand All @@ -17,35 +20,70 @@ public async Task<IFileUploadSiteFile> UploadFile(HttpClient httpClient, string
{
try
{
string jsonServer = await httpClient.GetStringAsync("https://api.gofile.io/servers");
GoFileIoServersResponse serversResponse = await httpClient.GetFromJsonAsync<GoFileIoServersResponse>("https://api.gofile.io/servers");

Check warning on line 23 in src/OpenDirectoryDownloader/FileUpload/GoFileIo.cs

View workflow job for this annotation

GitHub Actions / build (osx-x64, self-contained)

Using member 'System.Net.Http.Json.HttpClientJsonExtensions.GetFromJsonAsync<TValue>(HttpClient, String, CancellationToken)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.

Check warning on line 23 in src/OpenDirectoryDownloader/FileUpload/GoFileIo.cs

View workflow job for this annotation

GitHub Actions / build (linux-arm64, self-contained)

Using member 'System.Net.Http.Json.HttpClientJsonExtensions.GetFromJsonAsync<TValue>(HttpClient, String, CancellationToken)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.

Check warning on line 23 in src/OpenDirectoryDownloader/FileUpload/GoFileIo.cs

View workflow job for this annotation

GitHub Actions / build (linux-arm, self-contained)

Using member 'System.Net.Http.Json.HttpClientJsonExtensions.GetFromJsonAsync<TValue>(HttpClient, String, CancellationToken)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.

Check warning on line 23 in src/OpenDirectoryDownloader/FileUpload/GoFileIo.cs

View workflow job for this annotation

GitHub Actions / build (linux-x64, self-contained)

Using member 'System.Net.Http.Json.HttpClientJsonExtensions.GetFromJsonAsync<TValue>(HttpClient, String, CancellationToken)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.

Check warning on line 23 in src/OpenDirectoryDownloader/FileUpload/GoFileIo.cs

View workflow job for this annotation

GitHub Actions / build (win-x64, self-contained)

Using member 'System.Net.Http.Json.HttpClientJsonExtensions.GetFromJsonAsync<TValue>(HttpClient, String, CancellationToken)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.

JObject result = JObject.Parse(jsonServer);
if (serversResponse.Status != "ok")
{
throw new Exception("GoFile.io servers error, in maintenance?");
}

string server = serversResponse.Data.Servers.First().Name;

using HttpResponseMessage httpResponseMessageAccount = await httpClient.PostAsync("https://api.gofile.io/accounts", new StringContent("{}", Encoding.UTF8, "text/plain"));

GoFileIoAccountsResponse accountsResponse = await httpResponseMessageAccount.Content.ReadFromJsonAsync<GoFileIoAccountsResponse>();

Check warning on line 34 in src/OpenDirectoryDownloader/FileUpload/GoFileIo.cs

View workflow job for this annotation

GitHub Actions / build (osx-x64, self-contained)

Using member 'System.Net.Http.Json.HttpContentJsonExtensions.ReadFromJsonAsync<T>(HttpContent, CancellationToken)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.

Check warning on line 34 in src/OpenDirectoryDownloader/FileUpload/GoFileIo.cs

View workflow job for this annotation

GitHub Actions / build (linux-arm64, self-contained)

Using member 'System.Net.Http.Json.HttpContentJsonExtensions.ReadFromJsonAsync<T>(HttpContent, CancellationToken)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.

Check warning on line 34 in src/OpenDirectoryDownloader/FileUpload/GoFileIo.cs

View workflow job for this annotation

GitHub Actions / build (linux-arm, self-contained)

Using member 'System.Net.Http.Json.HttpContentJsonExtensions.ReadFromJsonAsync<T>(HttpContent, CancellationToken)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.

Check warning on line 34 in src/OpenDirectoryDownloader/FileUpload/GoFileIo.cs

View workflow job for this annotation

GitHub Actions / build (linux-x64, self-contained)

Using member 'System.Net.Http.Json.HttpContentJsonExtensions.ReadFromJsonAsync<T>(HttpContent, CancellationToken)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.

Check warning on line 34 in src/OpenDirectoryDownloader/FileUpload/GoFileIo.cs

View workflow job for this annotation

GitHub Actions / build (win-x64, self-contained)

Using member 'System.Net.Http.Json.HttpContentJsonExtensions.ReadFromJsonAsync<T>(HttpContent, CancellationToken)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.

if (accountsResponse.Status != "ok")
{
throw new Exception("GoFile.io accounts error, in maintenance?");
}

httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accountsResponse.Data.Token);

GoFileIoAccountResponse accountResponse = await httpClient.GetFromJsonAsync<GoFileIoAccountResponse>($"https://api.gofile.io/accounts/{accountsResponse.Data.Id}");

Check warning on line 43 in src/OpenDirectoryDownloader/FileUpload/GoFileIo.cs

View workflow job for this annotation

GitHub Actions / build (osx-x64, self-contained)

Using member 'System.Net.Http.Json.HttpClientJsonExtensions.GetFromJsonAsync<TValue>(HttpClient, String, CancellationToken)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.

Check warning on line 43 in src/OpenDirectoryDownloader/FileUpload/GoFileIo.cs

View workflow job for this annotation

GitHub Actions / build (linux-arm64, self-contained)

Using member 'System.Net.Http.Json.HttpClientJsonExtensions.GetFromJsonAsync<TValue>(HttpClient, String, CancellationToken)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.

Check warning on line 43 in src/OpenDirectoryDownloader/FileUpload/GoFileIo.cs

View workflow job for this annotation

GitHub Actions / build (linux-arm, self-contained)

Using member 'System.Net.Http.Json.HttpClientJsonExtensions.GetFromJsonAsync<TValue>(HttpClient, String, CancellationToken)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.

Check warning on line 43 in src/OpenDirectoryDownloader/FileUpload/GoFileIo.cs

View workflow job for this annotation

GitHub Actions / build (linux-x64, self-contained)

Using member 'System.Net.Http.Json.HttpClientJsonExtensions.GetFromJsonAsync<TValue>(HttpClient, String, CancellationToken)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.

Check warning on line 43 in src/OpenDirectoryDownloader/FileUpload/GoFileIo.cs

View workflow job for this annotation

GitHub Actions / build (win-x64, self-contained)

Using member 'System.Net.Http.Json.HttpClientJsonExtensions.GetFromJsonAsync<TValue>(HttpClient, String, CancellationToken)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.

if (accountResponse.Status != "ok")
{
throw new Exception("GoFile.io account error, in maintenance?");
}

using HttpResponseMessage httpResponseMessageCreateFolder = await httpClient.PostAsync("https://api.gofile.io/contents/createfolder", new StringContent($"{{\"parentFolderId\": \"{accountsResponse.Data.RootFolder}\"}}", Encoding.UTF8, "application/json"));

if (result["status"].Value<string>() == "error")
GoFileIoFolderResponse createFolderResponse = await httpResponseMessageCreateFolder.Content.ReadFromJsonAsync<GoFileIoFolderResponse>();

Check warning on line 52 in src/OpenDirectoryDownloader/FileUpload/GoFileIo.cs

View workflow job for this annotation

GitHub Actions / build (osx-x64, self-contained)

Using member 'System.Net.Http.Json.HttpContentJsonExtensions.ReadFromJsonAsync<T>(HttpContent, CancellationToken)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.

Check warning on line 52 in src/OpenDirectoryDownloader/FileUpload/GoFileIo.cs

View workflow job for this annotation

GitHub Actions / build (linux-arm64, self-contained)

Using member 'System.Net.Http.Json.HttpContentJsonExtensions.ReadFromJsonAsync<T>(HttpContent, CancellationToken)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.

Check warning on line 52 in src/OpenDirectoryDownloader/FileUpload/GoFileIo.cs

View workflow job for this annotation

GitHub Actions / build (linux-arm, self-contained)

Using member 'System.Net.Http.Json.HttpContentJsonExtensions.ReadFromJsonAsync<T>(HttpContent, CancellationToken)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.

Check warning on line 52 in src/OpenDirectoryDownloader/FileUpload/GoFileIo.cs

View workflow job for this annotation

GitHub Actions / build (linux-x64, self-contained)

Using member 'System.Net.Http.Json.HttpContentJsonExtensions.ReadFromJsonAsync<T>(HttpContent, CancellationToken)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.

Check warning on line 52 in src/OpenDirectoryDownloader/FileUpload/GoFileIo.cs

View workflow job for this annotation

GitHub Actions / build (win-x64, self-contained)

Using member 'System.Net.Http.Json.HttpContentJsonExtensions.ReadFromJsonAsync<T>(HttpContent, CancellationToken)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.

if (createFolderResponse.Status != "ok")
{
throw new Exception("GoFile.io error, probably in maintenance");
throw new Exception("GoFile.io create folder error, in maintenance?");
}

string server = result.SelectToken("data.servers").First()["name"].Value<string>();
using HttpResponseMessage httpResponseMessageUpdateFolder = await httpClient.PutAsync($"https://api.gofile.io/contents/{createFolderResponse.Data.Id}/update", new StringContent("{\"attribute\": \"public\", \"attributeValue\": \"true\"}", Encoding.UTF8, "application/json"));

GoFileIoFolderResponse updateFolderResponse = await httpResponseMessageUpdateFolder.Content.ReadFromJsonAsync<GoFileIoFolderResponse>();

Check warning on line 61 in src/OpenDirectoryDownloader/FileUpload/GoFileIo.cs

View workflow job for this annotation

GitHub Actions / build (osx-x64, self-contained)

Using member 'System.Net.Http.Json.HttpContentJsonExtensions.ReadFromJsonAsync<T>(HttpContent, CancellationToken)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.

Check warning on line 61 in src/OpenDirectoryDownloader/FileUpload/GoFileIo.cs

View workflow job for this annotation

GitHub Actions / build (linux-arm64, self-contained)

Using member 'System.Net.Http.Json.HttpContentJsonExtensions.ReadFromJsonAsync<T>(HttpContent, CancellationToken)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.

Check warning on line 61 in src/OpenDirectoryDownloader/FileUpload/GoFileIo.cs

View workflow job for this annotation

GitHub Actions / build (linux-arm, self-contained)

Using member 'System.Net.Http.Json.HttpContentJsonExtensions.ReadFromJsonAsync<T>(HttpContent, CancellationToken)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.

Check warning on line 61 in src/OpenDirectoryDownloader/FileUpload/GoFileIo.cs

View workflow job for this annotation

GitHub Actions / build (linux-x64, self-contained)

Using member 'System.Net.Http.Json.HttpContentJsonExtensions.ReadFromJsonAsync<T>(HttpContent, CancellationToken)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.

Check warning on line 61 in src/OpenDirectoryDownloader/FileUpload/GoFileIo.cs

View workflow job for this annotation

GitHub Actions / build (win-x64, self-contained)

Using member 'System.Net.Http.Json.HttpContentJsonExtensions.ReadFromJsonAsync<T>(HttpContent, CancellationToken)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.

if (updateFolderResponse.Status != "ok")
{
throw new Exception("GoFile.io update folder error, in maintenance?");
}

using FileStream fileStream = new(path, FileMode.Open);
using StreamContent streamContent = new(fileStream);

using MultipartFormDataContent multipartFormDataContent = new($"Upload----{Guid.NewGuid()}")
{
{ new StringContent(createFolderResponse.Data.Id), "folderId" },
{ streamContent, "file", Path.GetFileName(path) }
};

using HttpResponseMessage httpResponseMessage = await httpClient.PostAsync($"https://{server}.gofile.io/uploadFile", multipartFormDataContent);
using HttpResponseMessage httpResponseMessageUploadFile = await httpClient.PostAsync($"https://{server}.gofile.io/contents/uploadFile", multipartFormDataContent);

if (httpResponseMessage.IsSuccessStatusCode)
if (httpResponseMessageUploadFile.IsSuccessStatusCode)
{
string response = await httpResponseMessage.Content.ReadAsStringAsync();
OpenDirectoryIndexer.Session.UploadedUrlsResponse = response;
GoFileIoUploadFileResponse uploadFileResponse = await httpResponseMessageUploadFile.Content.ReadFromJsonAsync<GoFileIoUploadFileResponse>();

Check warning on line 81 in src/OpenDirectoryDownloader/FileUpload/GoFileIo.cs

View workflow job for this annotation

GitHub Actions / build (osx-x64, self-contained)

Using member 'System.Net.Http.Json.HttpContentJsonExtensions.ReadFromJsonAsync<T>(HttpContent, CancellationToken)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.

Check warning on line 81 in src/OpenDirectoryDownloader/FileUpload/GoFileIo.cs

View workflow job for this annotation

GitHub Actions / build (linux-arm64, self-contained)

Using member 'System.Net.Http.Json.HttpContentJsonExtensions.ReadFromJsonAsync<T>(HttpContent, CancellationToken)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.

Check warning on line 81 in src/OpenDirectoryDownloader/FileUpload/GoFileIo.cs

View workflow job for this annotation

GitHub Actions / build (linux-arm, self-contained)

Using member 'System.Net.Http.Json.HttpContentJsonExtensions.ReadFromJsonAsync<T>(HttpContent, CancellationToken)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.

Check warning on line 81 in src/OpenDirectoryDownloader/FileUpload/GoFileIo.cs

View workflow job for this annotation

GitHub Actions / build (linux-x64, self-contained)

Using member 'System.Net.Http.Json.HttpContentJsonExtensions.ReadFromJsonAsync<T>(HttpContent, CancellationToken)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.

Check warning on line 81 in src/OpenDirectoryDownloader/FileUpload/GoFileIo.cs

View workflow job for this annotation

GitHub Actions / build (win-x64, self-contained)

Using member 'System.Net.Http.Json.HttpContentJsonExtensions.ReadFromJsonAsync<T>(HttpContent, CancellationToken)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.
OpenDirectoryIndexer.Session.UploadedUrlsResponse = JsonSerializer.Serialize(uploadFileResponse);

Check warning on line 82 in src/OpenDirectoryDownloader/FileUpload/GoFileIo.cs

View workflow job for this annotation

GitHub Actions / build (osx-x64, self-contained)

Using member 'System.Text.Json.JsonSerializer.Serialize<TValue>(TValue, JsonSerializerOptions)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.

Check warning on line 82 in src/OpenDirectoryDownloader/FileUpload/GoFileIo.cs

View workflow job for this annotation

GitHub Actions / build (linux-arm64, self-contained)

Using member 'System.Text.Json.JsonSerializer.Serialize<TValue>(TValue, JsonSerializerOptions)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.

Check warning on line 82 in src/OpenDirectoryDownloader/FileUpload/GoFileIo.cs

View workflow job for this annotation

GitHub Actions / build (linux-arm, self-contained)

Using member 'System.Text.Json.JsonSerializer.Serialize<TValue>(TValue, JsonSerializerOptions)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.

Check warning on line 82 in src/OpenDirectoryDownloader/FileUpload/GoFileIo.cs

View workflow job for this annotation

GitHub Actions / build (win-x64, self-contained)

Using member 'System.Text.Json.JsonSerializer.Serialize<TValue>(TValue, JsonSerializerOptions)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.

Program.Logger.Debug("Response from {siteName}: {response}", Name, response);
Program.Logger.Debug("Response from {siteName}: {response}", Name, uploadFileResponse);

return JsonConvert.DeserializeObject<GoFileIoFile>(response);
return JsonSerializer.Deserialize<GoFileIoFile>(JsonSerializer.Serialize(uploadFileResponse));

Check warning on line 86 in src/OpenDirectoryDownloader/FileUpload/GoFileIo.cs

View workflow job for this annotation

GitHub Actions / build (osx-x64, self-contained)

Using member 'System.Text.Json.JsonSerializer.Deserialize<TValue>(String, JsonSerializerOptions)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.

Check warning on line 86 in src/OpenDirectoryDownloader/FileUpload/GoFileIo.cs

View workflow job for this annotation

GitHub Actions / build (linux-arm64, self-contained)

Using member 'System.Text.Json.JsonSerializer.Deserialize<TValue>(String, JsonSerializerOptions)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.

Check warning on line 86 in src/OpenDirectoryDownloader/FileUpload/GoFileIo.cs

View workflow job for this annotation

GitHub Actions / build (linux-arm, self-contained)

Using member 'System.Text.Json.JsonSerializer.Deserialize<TValue>(String, JsonSerializerOptions)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.

Check warning on line 86 in src/OpenDirectoryDownloader/FileUpload/GoFileIo.cs

View workflow job for this annotation

GitHub Actions / build (win-x64, self-contained)

Using member 'System.Text.Json.JsonSerializer.Deserialize<TValue>(String, JsonSerializerOptions)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.
}
else
{
Expand All @@ -69,20 +107,175 @@ public async Task<IFileUploadSiteFile> UploadFile(HttpClient httpClient, string

public class GoFileIoFile : IFileUploadSiteFile
{
public string Url => $"https://gofile.io/?c={Data.Code}";
public string Url => Data.DownloadPage;

[JsonProperty("status")]
[JsonPropertyName("status")]
public string Status { get; set; }

[JsonProperty("data")]
public GoFileIoFileData Data { get; set; }
[JsonPropertyName("data")]
public GoFileIoUploadedFile Data { get; set; }
}

public class GoFileIoFileData
{
[JsonProperty("code")]
[JsonPropertyName("code")]
public string Code { get; set; }

[JsonProperty("removalCode")]
[JsonPropertyName("removalCode")]
public string RemovalCode { get; set; }
}

public class GoFileIoResponse
{
[JsonPropertyName("status")]
public string Status { get; set; }
}

public class GoFileIoServersResponse : GoFileIoResponse
{
[JsonPropertyName("data")]
public GoFileIoServersData Data { get; set; }
}

public class GoFileIoServersData
{
[JsonPropertyName("servers")]
public List<GoFileIoServer> Servers { get; set; }
}

public class GoFileIoServer
{
[JsonPropertyName("name")]
public string Name { get; set; }

[JsonPropertyName("zone")]
public string Zone { get; set; }
}

public class GoFileIoFolderResponse : GoFileIoResponse
{
[JsonPropertyName("data")]
public GoFileIoFolder Data { get; set; }
}

public class GoFileIoFolder
{
[JsonPropertyName("code")]
public string Code { get; set; }

[JsonPropertyName("createTime")]
public int CreateTime { get; set; }

[JsonPropertyName("id")]
public string Id { get; set; }

[JsonPropertyName("modTime")]
public int ModTime { get; set; }

[JsonPropertyName("name")]
public string Name { get; set; }

[JsonPropertyName("owner")]
public string Owner { get; set; }

[JsonPropertyName("parentFolder")]
public string ParentFolder { get; set; }

[JsonPropertyName("type")]
public string Type { get; set; }
}

public class GoFileIoAccountsResponse : GoFileIoResponse
{
[JsonPropertyName("data")]
public GoFileIoAccount Data { get; set; }
}

public class GoFileIoAccount
{
[JsonPropertyName("id")]
public string Id { get; set; }

[JsonPropertyName("email")]
public string Email { get; set; }

[JsonPropertyName("rootFolder")]
public string RootFolder { get; set; }

[JsonPropertyName("tier")]
public string Tier { get; set; }

[JsonPropertyName("token")]
public string Token { get; set; }

[JsonPropertyName("statsCurrent")]
public GoFileIoAccountStats StatsCurrent { get; set; }
}

public class GoFileIoAccountResponse : GoFileIoResponse
{
[JsonPropertyName("data")]
public GoFileIoAccount Data { get; set; }
}

public class GoFileIoAccountStats
{
[JsonPropertyName("folderCount")]
public int FolderCount { get; set; }

[JsonPropertyName("fileCount")]
public int FileCount { get; set; }

[JsonPropertyName("storage")]
public int Storage { get; set; }
}

public class GoFileIoUploadFileResponse : IFileUploadSiteFile
{
[JsonPropertyName("data")]
public GoFileIoUploadedFile Data { get; set; }

public string Url => Data.DownloadPage;
}

public class GoFileIoUploadedFile
{
[JsonPropertyName("createTime")]
public int CreateTime { get; set; }

[JsonPropertyName("downloadPage")]
public string DownloadPage { get; set; }

[JsonPropertyName("guestToken")]
public string GuestToken { get; set; }

[JsonPropertyName("id")]
public string Id { get; set; }

[JsonPropertyName("md5")]
public string Md5 { get; set; }

[JsonPropertyName("mimetype")]
public string MimeType { get; set; }

[JsonPropertyName("modTime")]
public int ModTime { get; set; }

[JsonPropertyName("name")]
public string Name { get; set; }

[JsonPropertyName("parentFolder")]
public string ParentFolder { get; set; }

[JsonPropertyName("parentFolderCode")]
public string ParentFolderCode { get; set; }

[JsonPropertyName("servers")]
public List<string> Servers { get; set; }

[JsonPropertyName("size")]
public int Size { get; set; }

[JsonPropertyName("type")]
public string Type { get; set; }
}

0 comments on commit 586a49f

Please sign in to comment.