diff --git a/example/example.js b/example/example.js index 5deccd1..51fb5a2 100644 --- a/example/example.js +++ b/example/example.js @@ -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) - }); - - });