Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to download specific asset from task results. #167

Closed
ntr-808 opened this issue Sep 22, 2021 · 2 comments
Closed

Unable to download specific asset from task results. #167

ntr-808 opened this issue Sep 22, 2021 · 2 comments

Comments

@ntr-808
Copy link

ntr-808 commented Sep 22, 2021

It looks like no matter what asset file is specified as a URL param this handler is returning false.
I haven't yet tried to remove it but it looks like just removing that early return would see the desired functionality.

return false; // Invalid

@ntr-808
Copy link
Author

ntr-808 commented Sep 22, 2021

Quick update:

I removed the entire if statement and the following works as expected:

http://localhost:3000/task/0e021568-5bd0-41b1-80d0-e0fb58fb1c5a/download/odm_georeferencing%2Fodm_georeferenced_model.laz

@ntr-808
Copy link
Author

ntr-808 commented Sep 27, 2021

workaround that downloads a specific file from the all.zip

export async function downloadTask(taskId: Uuid): Promise<string> {
    const url = `http://nodeodm:3000/task/${taskId}/download/all.zip`;
    const outputDest = path.join(os.tmpdir(), `${taskId}.laz`);
    const res = await axios({ method: 'get', url, responseType: 'stream' });

    // looking for odm_georeferencing/odm_georeferenced_model.laz in the zip
    const ws = fs.createWriteStream(outputDest);
    const zipStream = unzip.Parse();
    res.data.pipe(zipStream)
        .on('entry', function unzipFile(entry: unzip.Entry) {
            if (entry.path === 'odm_georeferencing/odm_georeferenced_model.laz') {
                entry.pipe(ws);
            } else {
                entry.autodrain();
            }
        });

    const zipPromise = new Promise((resolve, reject) => {
        zipStream.on('close', resolve);
        zipStream.on('error', reject);
    });
    const writePromise = new Promise((resolve, reject) => {
        ws.on('close', resolve);
        ws.on('error', reject);
    });

    await Promise.all([zipPromise, writePromise]);
    return outputDest;
}

@ntr-808 ntr-808 closed this as completed Sep 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants