File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
src/content/docs/workflows/examples Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change 55 - Workflows
66 - D1
77 - R2
8+ languages :
9+ - Typescript
810pcx_content_type : configuration
911title : Backup and save D1 database
1012sidebar :
@@ -73,12 +75,14 @@ export class backupWorkflow extends WorkflowEntrypoint<Env, Params> {
7375 const res = await fetch (url , { method , headers , body: JSON .stringify (payload ) });
7476 const { result } = (await res .json ()) as any ;
7577
76- // The endpoint sends `signed_url` when the backup is ready.
78+ // The endpoint sends `signed_url` when the backup is ready to download .
7779 // If we don't get `signed_url` we throw to retry the step.
7880 if (! result ?.signed_url ) throw new Error (" Missing `signed_url`" );
7981
8082 const dumpResponse = await fetch (result .signed_url );
81- // We stream the file directly to R2
83+ if (! dumpResponse .ok ) throw new Error (" Failed to fetch dump file" );
84+
85+ // Finally, stream the file directly to R2
8286 await this .env .BACKUP_BUCKET .put (result .filename , dumpResponse .body );
8387 });
8488 }
You can’t perform that action at this time.
0 commit comments