Skip to content

Commit

Permalink
solve example.js for multizone
Browse files Browse the repository at this point in the history
  • Loading branch information
Allan-Nava authored Jun 11, 2024
1 parent 0baa868 commit 35428d1
Showing 1 changed file with 65 additions and 62 deletions.
127 changes: 65 additions & 62 deletions example/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,69 +74,72 @@ uploadButton.addEventListener("click", (event) => {
console.log("tangram.SIGNER_URL ", tangram.SIGNER_URL);
tangram.getZone().then((res) => {
consolele.log("zone ", res);
const zone = res.data.zone
const bucket_upload = res.data.bucket_upload
const access_key = res.data.access_key
const host = res.data.host
//form["region"] = zone
//window.categories = res;
const path = "upload/"+fileInput.files[0].name;
// renderlo dinamico @toninospiderman123
const config = {
signerUrl: "https://api-compress.hiway.media/api/v4.0/external/upload/sign_s3_url",
logging: true,
signHeaders: { tangram_key: apiKeyInput.value },
aws_url: host,
aws_key: access_key,
bucket: bucket_upload,
cloudfront: false,
progressIntervalMS: 1000, //interval every 1 sec update progress callback
sendCanonicalRequestToSignerUrl: true, // needed for minio s3
computeContentMd5: true,
cryptoMd5Method: (d) => btoa(SparkMD5.ArrayBuffer.hash(d, true)),
cryptoHexEncodedHash256: sha256,
}
Evaporate.create(config).then(evaporate => {

// disable all
uploadButton.disabled = true;
fileInput.disabled = true;
titleInput.disabled = true;
categorySelect.disabled = true;
progress.style.display = "block";
progressBar.style.width = "0%";


evaporate.add({
file: fileInput.files[0],
name: path,
progress: (percent, status) => {
console.log(percent, status)

// percent is between 0-1
progressBar.style.width = percent * 100 + "%";
},
complete: async (result) => {
console.log(result);
tangram.encode(path, fileInput.files[0], title, "", "", category).then((res) => {
// create upload video
alert("File uploaded successfully")
uploadButton.disabled = false;
fileInput.disabled = false;
titleInput.disabled = false;
categorySelect.disabled = false;
progress.style.display = "none";
progressBar.style.width = "0%";

}).catch((err) => {
alert(err)
})
},
error: (error) => {
alert(error)
}
})

}).catch(function (e) {
console.log(e)
});
});
//
const path = "upload/"+fileInput.files[0].name;
// renderlo dinamico @toninospiderman123
const config = {
signerUrl: "https://api-compress.hiway.media/api/v4.0/external/upload/sign_s3_url",
logging: true,
signHeaders: { tangram_key: apiKeyInput.value },
aws_url: ``,
aws_key: ``,
bucket: ``,
cloudfront: false,
progressIntervalMS: 1000, //interval every 1 sec update progress callback
sendCanonicalRequestToSignerUrl: true, // needed for minio s3
computeContentMd5: true,
cryptoMd5Method: (d) => btoa(SparkMD5.ArrayBuffer.hash(d, true)),
cryptoHexEncodedHash256: sha256,
}
Evaporate.create(config).then(evaporate => {

// disable all
uploadButton.disabled = true;
fileInput.disabled = true;
titleInput.disabled = true;
categorySelect.disabled = true;
progress.style.display = "block";
progressBar.style.width = "0%";


evaporate.add({
file: fileInput.files[0],
name: path,
progress: (percent, status) => {
console.log(percent, status)

// percent is between 0-1
progressBar.style.width = percent * 100 + "%";
},
complete: async (result) => {
console.log(result);
tangram.encode(path, fileInput.files[0], title, "", "", category).then((res) => {
// create upload video
alert("File uploaded successfully")
uploadButton.disabled = false;
fileInput.disabled = false;
titleInput.disabled = false;
categorySelect.disabled = false;
progress.style.display = "none";
progressBar.style.width = "0%";

}).catch((err) => {
alert(err)
})
},
error: (error) => {
alert(error)
}
})

}).catch(function (e) {
console.log(e)
});


});

0 comments on commit 35428d1

Please sign in to comment.