30 lines
1004 B
JavaScript
30 lines
1004 B
JavaScript
const fs = require('fs');
|
|
|
|
async function main() {
|
|
const tokenData = JSON.parse(fs.readFileSync('D:/cumin/ghaymah_dns_net_sec_tests/token.json', 'utf8'));
|
|
const topology = JSON.parse(fs.readFileSync('D:/cumin/ghaymah_dns_net_sec_tests/soc_project_topology.json', 'utf8'));
|
|
|
|
const gatewayId = topology.services.gateway.id;
|
|
const userId = tokenData.userId;
|
|
const token = tokenData.token;
|
|
|
|
const url = `https://s3-nhost-proxy-83e02743fd61.hosted.ghaymah.systems/files/${userId}/${gatewayId}.tar.gz`;
|
|
console.log('Testing upload to:', url);
|
|
|
|
const testData = fs.readFileSync('D:/cumin/ghaymah_dns_net_sec_tests/sample_artifact.tar.gz');
|
|
const res = await fetch(url, {
|
|
method: 'PUT',
|
|
headers: {
|
|
'Authorization': 'Bearer ' + token,
|
|
'Content-Type': 'application/gzip'
|
|
},
|
|
body: testData
|
|
});
|
|
|
|
console.log('Upload status:', res.status, res.statusText);
|
|
const text = await res.text();
|
|
console.log('Upload response text:', text);
|
|
}
|
|
|
|
main().catch(console.error);
|