We uploaded a bunch of LAZ files using the REST API. The upload is fine. And, I can see that LAZ files in the ION platform preview. However, when I want to download any of them I get the following error:
<Error>
<Code>NoSuchKey</Code>
<Message>The specified key does not exist.</Message>
<Key>sources/505034/XXXXXXX_combined.laz</Key>
<RequestId>CV4PPK9GQHWVAZEJ</RequestId>
<HostId>NmcjrGUuRAYQ8tBMIuxD/N0Ehl3ILmqbleheWxyKLU=</HostId>
</Error>
BTW, I can download the assets uploaded via File dialog / Cesium ION portal GUI interface as opposed to the REST API.
Kindly inform how to download files without getting this error. Thanks!
Hi @qiqbaltd, thank you for your question. Source data cannot be downloaded using the API, but if you tell us your use case, we may be able to provide an alternate recommendation. What is your goal with downloading source data from ion?
Thanks for the reply. I’m not downloading source data using the API. Instead, I’m using the Cesium ION GUI option to download data that Cesium has provided on the ION console. However, the problem I’m seeing is that I’m only able to download the data that were uploaded using the File Menu dialog box on the Cesium ION console (i.e., not using the API). However, if I use the API to upload the asset then go to the Cesium ION GUI option to download data then Cesium ION throws the error mentioned in the original message.
Thank you @qiqbaltd, I understand now. I tried this with a sample LAZ file, but I haven’t been able to reproduce the problem yet. If you are able, can you please share with us a data file for which this happens, so we can investigate internally? The script you used to upload the data would also be helpful, if you can provide that.
Thanks for the response. We have uploaded thousands of files using the Cesium REST API. Upload has been successful. And, after upload I have randomly picked many of them and tried to download them using the Cesium ION Gui Download feature and the error happens on all of them.
The script used is below, which is more or less the Cesium tutorial script:
'use strict';
// This is an example application that illustrates how to upload data
// to Cesium ion using Node.js. For a full walk-through of this example, see
// https://cesium.com/docs/tutorials/rest-api/
const AWS = require('aws-sdk');
const fs = require('fs');
const request = require('request-promise');
// Replace <your_access_token> below with a token from your ion account.
// This example requires a token with assets:list, assets:read, and assets:write scopes.
// Tokens page: https://cesium.com/ion/tokens
const accessToken = 'ACCESS_TOKEN';
// Sample data is already included in this repository, but you can modify the below
// path to point to any CityGML data you would like to upload.
const input = 'XXXXX.laz'; // # <----------------------
async function main()
{
// Step 1 POST information about the data to /v1/assets
console.log('Creating new asset: ' + input.split(".")[0]);
const response = await request({
url: 'https://api.cesium.com/v1/assets',
method: 'POST',
headers: { Authorization: `Bearer ${accessToken}` },
json: true,
body: {
name: input.split(".")[0],
description: 'This is a description',
attribution: 'This is an attribution',
type: '3DTILES', // # <---------------------- https://cesium.com/docs/rest-api/#operation/postAssets
options: {
sourceType: '3DTILES', // # <----------------------
position: [X, Y, Z], // # <----------------------
geometryCompression: 'NONE' // # <----------------------
}
}
});
// Step 2 Use response.uploadLocation to upoad the file to ion
console.log('Asset created. Uploading input');
const uploadLocation = response.uploadLocation;
const s3 = new AWS.S3({
apiVersion: '2006-03-01',
region: 'us-east-1',
signatureVersion: 'v4',
endpoint: uploadLocation.endpoint,
credentials: new AWS.Credentials(
uploadLocation.accessKey,
uploadLocation.secretAccessKey,
uploadLocation.sessionToken)
});
await s3.upload({
Body: fs.createReadStream(input),
Bucket: uploadLocation.bucket,
Key: `${uploadLocation.prefix}XXXXX.laz` // <-------------------------
}).on('httpUploadProgress', function (progress) {
console.log(`Upload: ${((progress.loaded / progress.total) * 100).toFixed(2)}%`);
}).promise();
// Step 3 Tell ion we are done uploading files.
const onComplete = response.onComplete;
await request({
url: onComplete.url,
method: onComplete.method,
headers: { Authorization: `Bearer ${accessToken}` },
json: true,
body: onComplete.fields
});
}
main().catch(e => {
console.log(e.message);
});
Thanks @qiqbaltd, I may have found the source of the problem, but I’m hoping you can verify one more thing for me. When you mouseover the Download button in the ion GUI for one of the assets (or right-click it and press Copy link address), what URL does it point to? I’m expecting that it goes to:
https://api.cesium.com/assets/505034/sources/XXXXXX_combined.laz
(for the asset with ID 505034, for example)
Where XXXXXX does not include a path (i.e., no slashes). Is that correct?
I have replaced some internal stuff with XXXX and YYYY. Notice the colon (’:’) is visible in the above, which perhaps may not be in a URL. And, that possibly is coming from the filename of the LAZ file itself. The filename itself is reported as, to the left of Download button:
D:\XXXX\LAZ\YYYY.laz
The corresponding error on clicking the Download button is:
<Error>
<Code>NoSuchKey</Code>
<Message>The specified key does not exist.</Message>
<Key>sources/467867/D:/XXXX/LAZ/YYYYY.laz</Key>
<RequestId>8ADV65AEJ95GGTEN</RequestId>
<HostId>A NUMBER here, that I removed</HostId>
</Error>
Hi @qiqbaltd, the fix for this issue is now live in ion. Please try again and let us know if you are able to download your source files, or if the problem persists.
Hi @qiqbaltd, great to hear! Glad it works and thanks again for the bug report.
We have a ticket open for adding a REST API to download source files, but it’s not on our immediate roadmap. We’ll be looking into it sometime after our current priorities (bathymetry, etc.).
If you wouldn’t mind sharing your use case (including what you’d be looking for with respect to frequency of downloads), we could take that into account.
As Matt mentioned, we hope you will give us an opportunity to hear more about your project and how Cesium can better suit your needs. Please let us know if you have any questions.