Convert Fonts

FREEMIUM
Par orthosie | Mise à jour 2 months ago | Tools
Health Check

N/A

Retour à toutes les discussions

"invalid file type"

Rapid account: Henning
henning
10 years ago

Hi
No matter what I do I get “Invalid file type” back.
I have done exactly as in the examples (node+curl) just changed “/tmp/path.to.font” to a real path (even tried with an invalid one too)

Something must be wrong with my account ? Any ideas ?

Rapid account: Orthosie
orthosie Commented 10 years ago

Can you try the same file from mashape api doc console and tell us if you see the same error?

Rapid account: Henning
henning Commented 10 years ago

I have tried the curl, php and node examples, but mostly tried from node js. Here is my node code:
´´´ var fs = require(‘fs’);
var unirest = require(‘unirest’);

var Request = unirest.post(“https://convertfonts.p.mashape.com/convert”)
.headers({
“X-Mashape-Authorization”: “9or1y0mfk71GiPDY7DIYmSW6aIrYv74b”
})
.send({
“target”: “woff”,

  //"font": "tru.ttf",                                                                              // Relative path                    -> result: msg: 'Invalid file type.', code: '1001' 
  //"font": "/var/www/henningOLD/bin/services/fonts/tru.ttf",                                       // Full path                        -> result: msg: 'Invalid file type.', code: '1001' 
  //"font": fs.readFileSync("/var/www/henningOLD/bin/services/fonts/tru.ttf"),                      // Send content as binary           -> ...413 Request Entity Too Large...
  //"font": escape(fs.readFileSync("/var/www/henningOLD/bin/services/fonts/tru.ttf", 'utf-8')),     // Send content as UTF-8, escaped   -> result: msg: 'Invalid file type.', code: '1001'
  
  //"font": "myriad.ttf",                                                                           // Relative path                    -> result: msg: 'Invalid file type.', code: '1001' 
  //"font": "/var/www/henningOLD/bin/services/fonts/myriad.ttf",                                    // Full path                        -> result: msg: 'Invalid file type.', code: '1001' 
  //"font": fs.readFileSync("/var/www/henningOLD/bin/services/fonts/myriad.ttf"),                   // Send content as binary           -> ...503 Service Temporarily Unavailable...
  //"font": escape(fs.readFileSync("/var/www/henningOLD/bin/services/fonts/myriad.ttf", 'utf-8')),  // Send content as UTF-8, escaped   -> result: msg: 'Invalid file type.', code: '1001'
  
  "font": '/var/www/henningOLD/bin/services/fonts/myriad.ttf',
  "binary": "false"
})
.end(function (response) {
  console.log(response);
});

´´´

Rapid account: Henning
henning Commented 10 years ago

It works fine from the mashape api doc console.

Rapid account: Henning
henning Commented 10 years ago

Error-code is 1001, “invalid file type” when trying from node js

Rapid account: Orthosie
orthosie Commented 10 years ago

If it works from the api doc console there is no problem with your font file. Can you send us the exact curl command you are executing?

Rapid account: Orthosie
orthosie Commented 10 years ago

We were able to successfully execute this and get the converted font back using the same font file located here…
http://henning.wapps.dk/henningOLD/bin/services/fonts/myriad.ttf
and using your key posted in the comment.

Most likely your node.js is not able to post the file successfully (permission issues?). Try the following python code and let us know.

BTW I think the issues can be viewed by everyone, which means anyone can see the key. You might want to revoke that key and request a new one from Mashape.

------------python-----------------
import unirest;

response = unirest.post(“https://convertfonts.p.mashape.com/convert”,

headers={
“X-Mashape-Authorization”: “…”
},
params={
“target”: “svg”,
“font”: open("./myriad.ttf", mode=“r”),
“binary”: “true”
}
);

print response.headers;
print response.body;
------------python-----------------

Let us know if we can close this issue.

Rapid account: Henning
henning Commented 10 years ago

The formatting of the code is a bit off above. The source-file is here: http://henning.wapps.dk/henningOLD/bin/services/fonts/doConvert.js

Rapid account: Henning
henning Commented 10 years ago

The python code worked perfectly and I can just call the python script from my node project.I will revoke the key.
Thanks for your support.

Participez à la discussion - ajoutez un commentaire ci-dessous:

Connectez-vous / Inscrivez-vous pour publier de nouveaux commentaires