| 31 | const client = new AssetServiceClient(); |
| 32 | |
| 33 | async function exportAssets() { |
| 34 | const projectId = await client.getProjectId(); |
| 35 | const projectResource = `projects/${projectId}`; |
| 36 | |
| 37 | // TODO(developer): choose the dump file path |
| 38 | // const dumpFilePath = 'Dump file path, e.g.: gs://<my_bucket>/<my_asset_file>' |
| 39 | const request = { |
| 40 | parent: projectResource, |
| 41 | contentType: contentType, |
| 42 | outputConfig: { |
| 43 | gcsDestination: { |
| 44 | uri: dumpFilePath, |
| 45 | }, |
| 46 | }, |
| 47 | }; |
| 48 | |
| 49 | // Handle the operation using the promise pattern. |
| 50 | const [operation] = await client.exportAssets(request); |
| 51 | |
| 52 | // Operation#promise starts polling for the completion of the operation. |
| 53 | const [result] = await operation.promise(); |
| 54 | |
| 55 | // Do things with with the response. |
| 56 | console.log(result); |
| 57 | } |
| 58 | exportAssets().catch(err => { |
| 59 | throw err; |
| 60 | }); |