File tree 1 file changed +22
-0
lines changed
mods/mods_available/kdmod/gui
1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -74,6 +74,28 @@ const request_examples = [
74
74
const resp = await this . fetch ( ...a ) ;
75
75
return await this . out ( resp ) ;
76
76
} ,
77
+ } ,
78
+ {
79
+ name : 'write file' ,
80
+ fetch : async ( path , str ) => {
81
+ const endpoint = `${ window . api_origin } /write` ;
82
+ const token = puter . authToken ;
83
+
84
+ const blob = new Blob ( [ str ] , { type : 'text/plain' } ) ;
85
+ const formData = new FormData ( ) ;
86
+ formData . append ( 'create_missing_ancestors' , true ) ;
87
+ formData . append ( 'path' , path ) ;
88
+ formData . append ( 'size' , 8 ) ;
89
+ formData . append ( 'overwrite' , true ) ;
90
+ formData . append ( 'file' , blob , 'something.txt' ) ;
91
+
92
+ const response = await fetch ( endpoint , {
93
+ method : 'POST' ,
94
+ headers : { 'Authorization' : `Bearer ${ token } ` } ,
95
+ body : formData
96
+ } ) ;
97
+ return await response . json ( ) ;
98
+ } ,
77
99
}
78
100
] ;
79
101
You can’t perform that action at this time.
0 commit comments