C# File Upload

Upload Files from C# Using HttpClient (No NuGet Vendor SDK)

Upload files from C# with HttpClient. No SDK, REST API, CDN delivery, prepaid credits.

If you build on ASP.NET Core, a Worker Service, a Blazor server app, or .NET MAUI, you already have the only HTTP client you need: HttpClient. Uploading a file to files.link is three awaited calls, no AWSSDK.S3 NuGet package, no credential provider chain, no IAM policy JSON. That keeps your published assembly lean — the AWS SDK alone adds several megabytes and a config surface most apps never touch.

The pattern is the same three steps you would use from any language, expressed idiomatically with IHttpClientFactory and StreamContent so large files never sit fully in managed memory. Step one POSTs metadata to /v1/files/{folderId} with the raw API key in the Authorization header (no Bearer prefix) and reads the presigned url and id out of the urls array. Step two PUTs the file stream to that URL. Step three POSTs the id list to /v1/files/confirm-upload.

csharp
record Slot(string url, string id);
record UploadResponse(bool success, Slot[] urls);

public async Task<string> Upload(HttpClient http, string folderId, string path)
{
    var key = Environment.GetEnvironmentVariable("FILESLINK_KEY");
    var meta = new { filesMetadata = new[] { new { name = Path.GetFileName(path), size = new FileInfo(path).Length, type = "image/png" } } };

    // Authorization is scoped per-request so it is NEVER sent to the presigned URL.
    var create = new HttpRequestMessage(HttpMethod.Post, $"https://api.files.link/v1/files/{folderId}") { Content = JsonContent.Create(meta) };
    create.Headers.Add("Authorization", key);
    var r1 = await http.SendAsync(create);
    var slot = (await r1.Content.ReadFromJsonAsync<UploadResponse>())!.urls[0];

    await using var fs = File.OpenRead(path);
    var put = new StreamContent(fs);
    put.Headers.ContentType = new MediaTypeHeaderValue("image/png"); // must match the type sent in create
    await http.PutAsync(slot.url, put); // presigned URL — no Authorization header

    var confirm = new HttpRequestMessage(HttpMethod.Post, "https://api.files.link/v1/files/confirm-upload") { Content = JsonContent.Create(new { ids = new[] { slot.id } }) };
    confirm.Headers.Add("Authorization", key);
    await http.SendAsync(confirm);
    return slot.id;
}

Register the client with services.AddHttpClient() so connection pooling and DNS refresh are handled for you, and keep the API key in user-secrets during development and Azure Key Vault or environment variables in production. Because files.link returns a CDN-backed URL per file, you can hand that URL straight to a Blazor component, an MVC view, or a MAUI Image control.

Visibility is per file: public files resolve directly over the global CDN, private files are issued short-lived signed URLs. Storage is encrypted at rest and metered against prepaid credits — no metered egress invoice waiting at month end.

Benefits With No Complexity

Global CDN delivery

Your files are served from 450+ edge locations worldwide.

Edge-cached worldwide

Files are cached close to your users for fast delivery.

Signed-URL security

Private files stay protected with time-limited access.

What You Get

Unlimited files

Upload as many files as you need.

Unlimited storage

There is no storage limit.

Public + Private storage

Private files are fully secured.

CDN ready links

Upload directly to 450+ edge locations worldwide.

Prepaid credits

No subscription. Pay only for the storage and bandwidth you use.

More coming soon

We have plenty of features coming!

How files.link Works

1. Upload

Create a project and upload your first file.

2. Copy

Copy the CDN link.

3. Use Anywhere

Paste and enjoy the blazing speed.

Why Developers Choose files.link

A Better Way to Store & Deliver Files

AWS S3 (AWSSDK.S3)Azure Blob (Azure.Storage.Blobs)files.link
Works with built-in HttpClient (no vendor NuGet)
Streams from disk via StreamContent
Global CDN delivery on every file
No credential provider chain to configure
Prepaid credits (no surprise bills)

Calculate Your Needs

Storage

0GB

Egress

0GB

CDN Bandwidth

0GB
Total: $0.000/month

Upload Files from C#

  • Global CDN delivery
  • Edge-cached worldwide
  • Signed-URL security
  • Unlimited files
  • Unlimited storage
  • Public + Private storage
  • No subscription — prepaid credits keep spend predictable
Start Uploading from C#

Frequently Asked Questions

Do I need the AWSSDK.S3 NuGet package?
No. All three steps go through the built-in HttpClient. You skip the AWS SDK, the credential provider chain, and the IAM policy entirely — just send the raw API key in the Authorization header.
How do I stream a large file without loading it into memory?
Wrap a FileStream in StreamContent and pass it to PutAsync. HttpClient streams the body to the presigned URL in chunks, so a multi-gigabyte upload never materializes in the managed heap.
How should I create the HttpClient in ASP.NET Core?
Use IHttpClientFactory via services.AddHttpClient(). It pools connections and handles DNS rotation, which avoids the socket-exhaustion problem you get from newing up HttpClient per request.
Does this work in .NET MAUI?
Yes. HttpClient is part of every .NET runtime, so the identical three-call flow runs from an iOS or Android MAUI app. The CDN URL you get back binds directly to an Image control.
Where do I store the API key in a .NET app?
Use dotnet user-secrets in development and Azure Key Vault or environment variables in production. Never check the key into appsettings.json or source control.
General Questions
Is there a subscription?
No. files.link uses prepaid credits, so storage, bandwidth, and API usage are deducted from your balance as you go. The app explains the payment step before uploads are enabled — no monthly subscription and no per-user fees.
What is files.link?
files.link is a developer-first file platform that makes it simple to store, secure, and deliver files globally. It provides signed URLs, public/private access, and an API-first design so you can integrate file delivery into any app without the usual complexity.
How does billing work?
files.link uses prepaid credits. As you use storage, bandwidth, and API requests, credits are deducted daily. When your balance runs low, we automatically recharge it using your saved card. If an auto-recharge doesn't go through, your files and links stay put — you simply update your payment method or top up manually to keep going. No monthly subscriptions — just simple usage-based pricing.
How secure is my data?
All files are encrypted at rest and in transit. You can use signed URLs for private files, control access with permissions, and rely on enterprise-grade infrastructure for data protection.

Related

files.link
Copyright © 2026
All rights reserved
ContactGuidesGlossaryStatusLegal