Skip to content

Commit

Permalink
async downloads
Browse files Browse the repository at this point in the history
  • Loading branch information
bodrovis committed Feb 7, 2025
1 parent 74f576f commit 6d8de6e
Show file tree
Hide file tree
Showing 11 changed files with 288 additions and 152 deletions.
25 changes: 25 additions & 0 deletions docs/additional_info/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
# Changelog

## 13.1.0 (07-Feb-2025)

* Added support for [async file downloads](https://developers.lokalise.com/reference/download-files-async):

```js
const process = await lokaliseApi
.files()
.async_download(projectId, params);

console.log(process.process_id);
```

The `process` is a [QueuedProcess](https://developers.lokalise.com/reference/queued-process-object). Then you can simply [fetch information about the process](https://developers.lokalise.com/reference/retrieve-a-process) and grab the bundle URL:

```js
const processInfo = await lokaliseApi
.queuedProcesses()
.get(process.process_id, { project_id: projectId });

processInfo.type; // => "async-export"
processInfo.status; // => "finished"
processInfo.details.total_number_of_keys; // => 14
processInfo.details.download_url // => "https://lokalise-live-lok-s3-fss-export.s3.eu-central-1.amazonaws.com/..."
```

## 13.0.0 (12-Dec-2024)

* Reworked code, make types stricter and error handling better
Expand Down
28 changes: 28 additions & 0 deletions docs/api/files.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,34 @@ const response = await lokaliseApi.files().download(project_id,
response.bundle_url;
```

## Download translation files (async)

[API doc](https://developers.lokalise.com/reference/download-files-async)

Starts a project export process.

```js
const projectId = "123.abc";
const process = await lokaliseApi.files().async_download(projectId,
{format: 'json', "original_filenames": true}
);

const process_id = process.process_id;
```

Once complete, the download URL can be accessed using the [Retrieve process API endpoint](https://developers.lokalise.com/reference/retrieve-a-process):

```js
const processInfo = await lokaliseApi
.queuedProcesses()
.get(process_id, { project_id: projectId });

processInfo.type; // => "async-export"
processInfo.status; // => "finished"
processInfo.details.total_number_of_keys; // => 14
processInfo.details.download_url // => "https://lokalise-live-lok-s3-fss-export.s3.eu-central-1.amazonaws.com/..."
```

## Upload translation file

[API doc](https://developers.lokalise.com/reference/upload-a-file)
Expand Down
Loading

0 comments on commit 6d8de6e

Please sign in to comment.