fix s3 adapter

This commit is contained in:
dswbx
2025-02-14 11:42:26 +01:00
parent 9c38c8f2ad
commit 24e69eec90
6 changed files with 16 additions and 25 deletions

View File

@@ -124,7 +124,8 @@ export class AppMedia extends Module<typeof mediaConfigSchema> {
async (e) => { async (e) => {
const mutator = em.mutator(media); const mutator = em.mutator(media);
mutator.__unstable_toggleSystemEntityCreation(false); mutator.__unstable_toggleSystemEntityCreation(false);
await mutator.insertOne(this.uploadedEventDataToMediaPayload(e.params)); const payload = this.uploadedEventDataToMediaPayload(e.params);
await mutator.insertOne(payload);
mutator.__unstable_toggleSystemEntityCreation(true); mutator.__unstable_toggleSystemEntityCreation(true);
console.log("App:storage:file uploaded", e); console.log("App:storage:file uploaded", e);
}, },

View File

@@ -89,7 +89,8 @@ export class MediaController extends Controller {
); );
} }
return c.json(await this.getStorage().uploadFile(body, filename), HttpStatus.CREATED); const res = await this.getStorage().uploadFile(body, filename);
return c.json(res, HttpStatus.CREATED);
}); });
// add upload file to entity // add upload file to entity

View File

@@ -80,7 +80,6 @@ export class Storage implements EmitsEvents {
noEmit?: boolean noEmit?: boolean
): Promise<FileUploadedEventData> { ): Promise<FileUploadedEventData> {
const result = await this.#adapter.putObject(name, file); const result = await this.#adapter.putObject(name, file);
console.log("result", result);
let info: FileUploadPayload; let info: FileUploadPayload;

View File

@@ -122,18 +122,7 @@ export class StorageS3Adapter extends AwsClient implements StorageAdapter {
if (res.ok) { if (res.ok) {
// "df20fcb574dba1446cf5ec997940492b" // "df20fcb574dba1446cf5ec997940492b"
const etag = String(res.headers.get("etag")); return String(res.headers.get("etag"));
if (isFile(body)) {
return {
etag,
name: body.name,
meta: {
size: body.size,
type: body.type
}
};
}
return etag;
} }
return undefined; return undefined;

View File

@@ -225,12 +225,12 @@ export function FormContextOverride({
// especially useful for AnyOf, since it doesn't need to fully validate (e.g. pattern) // especially useful for AnyOf, since it doesn't need to fully validate (e.g. pattern)
if (prefix) { if (prefix) {
additional.root = prefix; additional.root = prefix;
additional.setValue = (pointer: string, value: any) => { /*additional.setValue = (path: string, value: any) => {
ctx.setValue(prefixPointer(pointer, prefix), value); ctx.setValue(prefixPath(path, prefix), value);
};
additional.deleteValue = (pointer: string) => {
ctx.deleteValue(prefixPointer(pointer, prefix));
}; };
additional.deleteValue = (path: string) => {
ctx.deleteValue(prefixPath(path, prefix));
};*/
} }
const context = { const context = {

View File

@@ -46,7 +46,7 @@ export default function JsonSchemaForm3() {
return ( return (
<Scrollable> <Scrollable>
<div className="flex flex-col p-3"> <div className="flex flex-col p-3">
<Form {/*<Form
onChange={(data) => console.log("change", data)} onChange={(data) => console.log("change", data)}
onSubmit={(data) => console.log("submit", data)} onSubmit={(data) => console.log("submit", data)}
schema={{ schema={{
@@ -68,7 +68,7 @@ export default function JsonSchemaForm3() {
className="flex flex-col gap-3" className="flex flex-col gap-3"
validateOn="change" validateOn="change"
options={{ debug: true }} options={{ debug: true }}
/> />*/}
{/*<Form {/*<Form
schema={{ schema={{
@@ -249,12 +249,13 @@ export default function JsonSchemaForm3() {
</Form>*/} </Form>*/}
{/*<CustomMediaForm />*/} {/*<CustomMediaForm />*/}
{/*<Form <Form
schema={schema.media} schema={schema.media}
initialValues={config.media as any} initialValues={config.media as any}
onSubmit={console.log} onSubmit={console.log}
validateOn="change" options={{ debug: true }}
/>*/} /*validateOn="change"*/
/>
{/*<Form {/*<Form
schema={removeKeyRecursively(schema.media, "pattern") as any} schema={removeKeyRecursively(schema.media, "pattern") as any}