Skip to content

Commit 5dfea32

Browse files
committed
Save to caterva2
1 parent db7eec4 commit 5dfea32

4 files changed

Lines changed: 22 additions & 4 deletions

File tree

.github/workflows/build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
push:
55
branches:
66
- main
7+
- caterva2
78
pull_request:
89
branches:
910
- '*'

.github/workflows/check-release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
name: Check Release
22
on:
33
push:
4-
branches:
5-
- '*'
4+
branches-ignore:
5+
- caterva2
66
pull_request:
77
branches:
88
- '*'

.github/workflows/ui-tests.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
name: UI Tests
22

3-
on: [push, pull_request]
3+
on:
4+
push:
5+
branches-ignore:
6+
- caterva2
7+
pull_request:
8+
branches:
9+
- '*'
410

511
env:
612
CACHE_EPOCH: 0

packages/contents/src/contents.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@ export class Contents implements IContents {
398398
*/
399399
async save(path: string, options: Partial<IModel> = {}): Promise<IModel | null> {
400400
path = decodeURIComponent(path);
401+
//this.c2upload(path, options.content);
401402

402403
// process the file if coming from an upload
403404
const ext = PathExt.extname(options.name ?? '');
@@ -505,10 +506,20 @@ export class Contents implements IContents {
505506
item = { ...item, size: 0 };
506507
}
507508

508-
await (await this.storage).setItem(path, item);
509+
//await (await this.storage).setItem(path, item);
510+
this.c2upload(path, item.content);
509511
return item;
510512
}
511513

514+
async c2upload(path: string, content: object) {
515+
const filename = path.split('/').pop();
516+
const jsonstr = JSON.stringify(content);
517+
const blob = new Blob([jsonstr]);
518+
const formData = new FormData();
519+
formData.append('file', blob, filename);
520+
fetch(`/api/upload/${path}`, { method: 'POST', body: formData });
521+
}
522+
512523
/**
513524
* Delete a file from browser storage.
514525
*

0 commit comments

Comments
 (0)