Skip to content
This repository has been archived by the owner on Mar 13, 2019. It is now read-only.

Commit

Permalink
Finish trying out the CloudConvert API
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubuntu committed Jul 1, 2014
1 parent 80669dc commit 4b178d1
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions visualization/static/visualization/js/exports.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,20 @@ var exportExtensions = {
* @param fileName
*/
var startConversionProcess = function(processUrl, outputFormat, fileUrl, fileName) {
var publicFileUrl = window.location.origin + fileUrl;
console.log(publicFileUrl);
console.log(outputFormat)
var realProcessUrl = 'https:'+processUrl;
console.log(realProcessUrl);
console.log(fileName);

$.ajax({
url: 'https:'+processUrl,
type: 'POST',
dataType: 'json',
data: {
input: "download",
file: fileUrl,
file: publicFileUrl,
filename: fileName,
outputformat: outputFormat
},
Expand Down Expand Up @@ -71,8 +77,15 @@ var createProcessID = function(outputFormat, fileUrl, filename) {
},
success: function(response) {
if (response.url !== undefined) {
var processUrl = response.url;
startConversionProcess(processUrl, outputFormat, fileUrl, filename);
var processUrl = response.url
var regex = /\/([^\/]+\.[a-zA-Z]+)$/;
var regexResult = regex.exec(fileUrl);
if (regexResult) {
var realFileName = regexResult[1];
startConversionProcess(processUrl, outputFormat, fileUrl, realFileName);
}


}
},
error: function() {
Expand Down Expand Up @@ -134,9 +147,9 @@ var sendSVGInfo = function(filename) {
success: function(response) {
if (response.success === 1) {
createProcessID(response['extension'],response['url'], response['filename']);
console.log(response['extension']);
console.log(response['filename']);
console.log(response['url']);
console.log('Extension: '+response['extension']);
console.log('Filename: '+response['filename']);
console.log('Url: '+response['url']);

}

Expand Down

0 comments on commit 4b178d1

Please sign in to comment.