File tree 1 file changed +5
-7
lines changed
1 file changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -29,19 +29,17 @@ export async function onRequestPost(context) { // Contents of context object
29
29
30
30
const fileId = new Date ( ) . getTime ( ) ;
31
31
const fileExtension = fileName . split ( '.' ) . pop ( ) ;
32
- const newFilePath = `/file/v1/${ fileId } .${ fileExtension } ` ;
33
-
32
+ const key = fileId + "." + fileExtension ;
34
33
try {
35
- await env . img_static . put ( newFilePath , fileContent ) ;
36
- const key = fileId + "." + fileExtension ;
37
- await env . img_url . put ( key , newFilePath , {
38
- metadata : { ListType : "None" , Label : "None" , TimeStamp : new Date ( ) . time ( ) }
34
+ await env . img_static . put ( key , fileContent ) ;
35
+ await env . img_url . put ( key , "" , {
36
+ metadata : { ListType : "None" , Label : "None" , TimeStamp : fileId }
39
37
}
40
38
) ;
41
39
} catch ( error ) {
42
40
return new Response ( `Upload fail` , { status : 400 } ) ;
43
41
}
44
- return new Response ( `[{\"src\":\"${ newFilePath } \"}]` ) ;
42
+ return new Response ( `[{\"src\":\"/file/v1/ ${ newFilePath } \"}]` ) ;
45
43
}
46
44
47
45
async function parseMultipartFormData ( request ) {
You can’t perform that action at this time.
0 commit comments