mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2024-11-19 01:43:50 +01:00
25ae6df095
* Greenfield: Add file endpoints and upload - Endpoints for server files - File upload using `multipart/form-data` Closes #6074. Can also be tested using cURL: - `curl --location 'https://localhost:14142/api/v1/files' --header 'Authorization: token MY_API_TOKEN' --form 'file=@"LOCAL_FILEPATH"'` - `curl --location 'https://localhost:14142/api/v1/users/me/picture' --header 'Authorization: token MY_API_TOKEN' --form 'file=@"LOCAL_FILEPATH"'` * Revert UnresolvedUri changes * Add upload for store logo
30 lines
1.0 KiB
C#
30 lines
1.0 KiB
C#
using System.Net.Http;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using BTCPayServer.Client.Models;
|
|
|
|
namespace BTCPayServer.Client;
|
|
|
|
public partial class BTCPayServerClient
|
|
{
|
|
public virtual async Task<FileData[]> GetFiles(CancellationToken token = default)
|
|
{
|
|
return await SendHttpRequest<FileData[]>("api/v1/files", null, HttpMethod.Get, token);
|
|
}
|
|
|
|
public virtual async Task<FileData> GetFile(string fileId, CancellationToken token = default)
|
|
{
|
|
return await SendHttpRequest<FileData>($"api/v1/files/{fileId}", null, HttpMethod.Get, token);
|
|
}
|
|
|
|
public virtual async Task<FileData> UploadFile(string filePath, string mimeType, CancellationToken token = default)
|
|
{
|
|
return await UploadFileRequest<FileData>("api/v1/files", filePath, mimeType, "file", HttpMethod.Post, token);
|
|
}
|
|
|
|
public virtual async Task DeleteFile(string fileId, CancellationToken token = default)
|
|
{
|
|
await SendHttpRequest($"api/v1/files/{fileId}", null, HttpMethod.Delete, token);
|
|
}
|
|
}
|