@axium/storage 0.23.0 → 0.23.2

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.
@@ -52,6 +52,7 @@ async function _upload(upload, stream, itemSize, onProgress) {
52
52
  const headers = {
53
53
  'x-upload': upload.token,
54
54
  'x-offset': offset.toString(),
55
+ 'x-chunk-size': chunkSize.toString(),
55
56
  'content-length': chunkSize.toString(),
56
57
  'content-type': 'application/octet-stream',
57
58
  };
@@ -49,9 +49,9 @@ addRoute({
49
49
  if (!getConfig('@axium/storage').enabled)
50
50
  error(503, 'User storage is disabled');
51
51
  const upload = await requireUpload(request);
52
- const size = BigInt(request.headers.get('content-length') || -1);
52
+ const size = BigInt(request.headers.get('x-chunk-size') || -1);
53
53
  if (size < 0n)
54
- error(411, 'Missing or invalid content length');
54
+ error(411, 'Missing or invalid chunk size');
55
55
  if (upload.uploadedBytes + size > upload.init.size)
56
56
  error(413, 'Upload exceeds allowed size');
57
57
  const offset = BigInt(request.headers.get('x-offset') || -1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axium/storage",
3
- "version": "0.23.0",
3
+ "version": "0.23.2",
4
4
  "author": "James Prevett <axium@jamespre.dev>",
5
5
  "description": "User file storage for Axium",
6
6
  "funding": {
@@ -27,11 +27,13 @@
27
27
  }
28
28
 
29
29
  function useAndClearActive(thunk: () => any) {
30
- if (!activeItem) throw text('storage.generic.no_item');
31
- const result = thunk();
32
- const index = items.findIndex(item => item.id === activeId);
33
- if (index !== -1) items.splice(index, 1);
34
- return result;
30
+ return () => {
31
+ if (!activeItem) throw text('storage.generic.no_item');
32
+ const result = thunk();
33
+ const index = items.findIndex(item => item.id === activeId);
34
+ if (index !== -1) items.splice(index, 1);
35
+ return result;
36
+ };
35
37
  }
36
38
  </script>
37
39