Archived from the Transloadit support forum. Originally posted on November 13, 2013; details may be outdated, see our docs for current behavior. Original thread
Hi Guys,
I’m busy tracking down an issue where we are receiving an IMPORT_FILE_ERROR error.
There is only one redirect from our service to S3 where the files are.
I’ve picked up that we are not mapping the filenames correctly on our side in some instances.
It would be great if you could give me some insight into the function used on your side to escape file names.
It looks like we might not be handling special characters the same way that you are causing our mapping to fail.
If that makes sense.
Thanks!
Nicolaas van der Westhuizen
[email blocked]
do you mind sharing some file names where this occurred?
As for the filenames - S3 doesn’t allow us to push special character filenames, so for the ${file.urlName} and ${file.urlBasename} assembly variables (that you probably use), we do this:
str.urlSanitize = function(s) {
s = s.replace(/ /g, ‘-’); s = s.replace(/[^A-Za-z0-9-_.]/g, ‘_’); return s; };
So we are replacing every special character with an underscore.
We implemented our code according to the documentation that states:
${file.url_name} The name of the file, from which any characters other than A-Za-z0-9-_. are stripped, and with spaces replaced with dashes. This includes the file extension as well.
and
${file.url_basename} The basename of the file (the file name without the file extension), from which any characters other thanA-Za-z0-9-_. are stripped, and with spaces replaced with dashes.
But I picked up that you were in fact using underscores and changed our implementation.
We received a couple of IMPORT_FILE_ERROR’s today, again.
I’m looking into it at the moment as I’m not entirely convinced that the issue is not on our side.
right, I will updated the docs accordingly, stating that any non alphanumeric character will be replaced with an underscore.
The problem is that we cannot strip them. Some of our customers (like Chinese people) could not export any files to s3 if the filename was just “.mp3”.
Sorry for the inconvenience and the inaccuracy of the docs there.