Skip to content

Commit

Permalink
chore: sync key usage on upload (#998)
Browse files Browse the repository at this point in the history
  • Loading branch information
juliusmarminge authored Oct 7, 2024
1 parent a3fa6af commit d4d453d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/popular-forks-speak.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"uploadthing": patch
---

chore: send version header when uploading to have accurate version shown on dashboard
2 changes: 2 additions & 0 deletions packages/uploadthing/src/internal/upload.browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as Micro from "effect/Micro";
import type { FetchError } from "@uploadthing/shared";
import { FetchContext, fetchEff, UploadThingError } from "@uploadthing/shared";

import { version } from "../../package.json";
import type {
ClientUploadedFileData,
FileRouter,
Expand All @@ -26,6 +27,7 @@ const uploadWithProgress = (
const xhr = new XMLHttpRequest();
xhr.open("PUT", presigned.url, true);
xhr.setRequestHeader("Range", `bytes=${rangeStart}-`);
xhr.setRequestHeader("x-uploadthing-version", version);
xhr.responseType = "json";

let previousLoaded = 0;
Expand Down
2 changes: 2 additions & 0 deletions packages/uploadthing/src/internal/upload.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { unsafeCoerce } from "effect/Function";

import { UploadThingError } from "@uploadthing/shared";

import { version } from "../../package.json";
import type { FileEsque } from "../sdk/types";
import type { UploadPutResult } from "./types";

Expand All @@ -23,6 +24,7 @@ export const uploadWithoutProgress = (
const json = yield* HttpClientRequest.put(presigned.url).pipe(
HttpClientRequest.formDataBody(formData),
HttpClientRequest.setHeader("Range", "bytes=0-"),
HttpClientRequest.setHeader("x-uploadthing-version", version),
HttpClient.filterStatusOk(httpClient),
Effect.mapError(
(e) =>
Expand Down

0 comments on commit d4d453d

Please sign in to comment.