@geode/opengeodeweb-front 10.34.0-rc.18 → 10.34.0-rc.19

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.
@@ -133,6 +133,7 @@ export const useBackStore = defineStore("back", {
133
133
  {
134
134
  schema,
135
135
  file,
136
+ raw: true,
136
137
  },
137
138
  {
138
139
  ...callbacks,
@@ -9,6 +9,10 @@ interface UploadFileParams {
9
9
  schema: JsonRpcSchema & { methods: string[] };
10
10
  file: File;
11
11
  params?: Record<string, string | Blob>;
12
+ // When true, the file is sent as the raw request body instead of multipart
13
+ // FormData, with `params`/filename moved into the query string. See
14
+ // OpenGeodeWeb-Back's upload_file route, which supports both request shapes.
15
+ raw?: boolean;
12
16
  }
13
17
 
14
18
  // Loosely-typed shapes for the dynamic error/response values reported by fetchRaw.
@@ -34,7 +38,7 @@ function isFetchErrorResponseLike(value: unknown): value is FetchErrorResponseLi
34
38
 
35
39
  async function upload_file(
36
40
  microservice: Microservice,
37
- { schema, file, params = {} }: UploadFileParams,
41
+ { schema, file, params = {}, raw = false }: UploadFileParams,
38
42
  { request_error_function, response_function, response_error_function }: RequestHandlers = {},
39
43
  ): Promise<unknown> {
40
44
  console.log("[UPLOAD_FILE] Uploading file", { schema, file });
@@ -44,14 +48,25 @@ async function upload_file(
44
48
  throw new Error("file must be an instance of File");
45
49
  }
46
50
 
47
- const body = new FormData();
48
- for (const [key, value] of Object.entries(params)) {
49
- body.append(key, value);
51
+ let route = schema.$id;
52
+ let body: FormData | File = file;
53
+
54
+ if (raw) {
55
+ const queryEntries = Object.entries(params).filter(
56
+ (entry): entry is [string, string] => typeof entry[1] === "string",
57
+ );
58
+ const query = new URLSearchParams([...queryEntries, ["filename", file.name]]);
59
+ route = `${route}?${query.toString()}`;
60
+ } else {
61
+ const formData = new FormData();
62
+ for (const [key, value] of Object.entries(params)) {
63
+ formData.append(key, value);
64
+ }
65
+ formData.append("file", file);
66
+ body = formData;
50
67
  }
51
- body.append("file", file);
52
68
 
53
69
  microservice.start_request();
54
- const route = schema.$id;
55
70
 
56
71
  const result = await fetchRaw(
57
72
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geode/opengeodeweb-front",
3
- "version": "10.34.0-rc.18",
3
+ "version": "10.34.0-rc.19",
4
4
  "description": "OpenSource Vue/Nuxt/Pinia/Vuetify framework for web applications",
5
5
  "homepage": "https://github.com/Geode-solutions/OpenGeodeWeb-Front",
6
6
  "bugs": {