cloudrop 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -6,6 +6,26 @@ Every notable change to the `cloudrop` package. The format follows
6
6
 
7
7
  ## Unreleased
8
8
 
9
+ ## 0.1.1 - 2026-11-20
10
+
11
+ ### Fixed
12
+
13
+ - **R2: a text, JSON, HTML or SVG file of 50 bytes or more failed at `/complete` with `502 STORAGE_ERROR`** ("The
14
+ storage service's response had no content length"), after its bytes had reached the bucket. R2 compresses its answer
15
+ to the `HEAD` request that reads the stored size when the request offers gzip, as Node's and Bun's `fetch` do, and
16
+ then sends no `Content-Length`. The driver now asks for an uncompressed answer on every `HEAD`, which also fixes
17
+ `/abort`, the store's sweep and `api.head` on such files, for `r2()` and for `s3()` pointed at R2. Applications that
18
+ set `accept-encoding: identity` in a `fetch` of their own can drop it.
19
+
20
+ ### Documentation
21
+
22
+ - **Signed-in users in React:** the React guide shows a client per user, in a context keyed by the user, and a sign-out
23
+ that cancels every route's uploads before `forget()`: `forget()` stops nothing, and a file that gets its ticket
24
+ afterwards saves a new record and, once the session changed, asks `/upload` with the next user's session. The Vite
25
+ example's sign-out now does the same.
26
+ - **What "`onComplete` once" means:** at least once without a store; with one, once under a lease, and exactly once only
27
+ for writes through `tx` on Postgres with `transaction: true`. Keep an email or a webhook idempotent.
28
+
9
29
  ## 0.1.0 - 2026-11-19
10
30
 
11
31
  The first release. Version `0.0.0` on npm only reserved the name.
package/README.md CHANGED
@@ -70,9 +70,15 @@ export function AvatarPicker() {
70
70
 
71
71
  Without React, `createCloudropClient` from `cloudrop/client` gives you `upload()`, which resolves to `{ data, error }`.
72
72
 
73
- To keep a row per upload in your own database, with `onComplete` once per file, a quota per user, revocation and a
74
- sweep for abandoned uploads, pass a store from `cloudrop/adapters/sql`, `cloudrop/adapters/drizzle` or
75
- `cloudrop/adapters/prisma`: [Database store](https://github.com/vcode-sh/cloudrop/blob/main/docs/guide/store.md).
73
+ When users sign in, give each user a client of their own and cancel their uploads before `forget()` at sign-out:
74
+ [Signed-in users](https://github.com/vcode-sh/cloudrop/blob/main/docs/guide/react.md#signed-in-users).
75
+
76
+ `onComplete` runs at least once per file: a client that lost the answer to `/complete` asks again, so make it
77
+ idempotent before it sends an email or calls a webhook. To keep a row per upload in your own database, with a quota per
78
+ user, revocation and a sweep for abandoned uploads, pass a store from `cloudrop/adapters/sql`,
79
+ `cloudrop/adapters/drizzle` or `cloudrop/adapters/prisma`. With a store, `onComplete` runs once per file, except after a
80
+ crash, a throw or a run longer than its lease; only its writes through `tx` on Postgres with `transaction: true` commit
81
+ exactly once: [Database store](https://github.com/vcode-sh/cloudrop/blob/main/docs/guide/store.md#what-it-guarantees).
76
82
 
77
83
  ## Bucket setup
78
84
 
package/dist/index.js CHANGED
@@ -2384,10 +2384,14 @@ async function send(ctx, method, url, options = {}) {
2384
2384
  date: now(),
2385
2385
  payloadHash: body instanceof Blob ? UNSIGNED_PAYLOAD : body ? await sha256Hex(body) : EMPTY_SHA256
2386
2386
  });
2387
+ const sent = method === "HEAD" ? {
2388
+ ...signed,
2389
+ "accept-encoding": "identity"
2390
+ } : signed;
2387
2391
  try {
2388
2392
  const response = await http(url, {
2389
2393
  method,
2390
- headers: signed,
2394
+ headers: sent,
2391
2395
  body,
2392
2396
  signal: AbortSignal.timeout(timeoutMs)
2393
2397
  });