-
Notifications
You must be signed in to change notification settings - Fork 16
Open
Description
Hi,
I'm trying to translate it to react. I manage to make the first part with axios.
axios.post('https://api.cesium.com/v1/assets', {
name: selectedFile.name,
description: '',
type: '3DTILES',
options: {
position:[ 2.29, 48.85, 0.1],
sourceType: srcType
}
},{
headers: { Authorization: `Bearer ${accessToken}` }
})
.then(response => sendtos3(response))
.catch(function (error) {
console.log(error);
});`
Then my sendtos3 function is like this :
async function sendtos3(response){
const uploadLocation = response.data.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)
});
const params = {
Body: selectedFile,
Bucket: uploadLocation.bucket,
Key: selectedFile.name
};
await s3.upload({
Body: selectedFile,
Bucket: uploadLocation.bucket,
Key: selectedFile.name
}).on('httpUploadProgress', function (progress) {
console.log(`Upload: ${((progress.loaded / progress.total) * 100).toFixed(2)}%`);
}).promise();
} `
But I always get a : Failed to load resource: the server responded with a status of 403 (Forbidden).
When I check my credential, every thing seam to be ok.
Edited by javagl for code formatting
Metadata
Metadata
Assignees
Labels
No labels