Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

tfilefetch and file extension

Hi,
is there a way to get the file extension (.jpeg, .gif, .bmp for exemple) of a file fetched with a tfilefetch component ?
Thanks
Regards
Labels (2)
11 Replies
Anonymous
Not applicable
Author

Hi
You can't get extension from tfilefetch directly.
But you may save it into local disk and use tFileProperties to get extension.
Regards,
Pedro
Anonymous
Not applicable
Author

tFileProperties gives :
- abs_path
- dirname
- basename
- mode_string
- size
- mtime
- mtime_string

==> where is the file extension property please ?
Regards
Anonymous
Not applicable
Author

Hi
Link tFileProperties with tMap.
Set expression of basename.
Get extension at the right of "." .
row1.basename.substring(StringHandling.INDEX(row1.basename,".")+1)

Regards,
Pedro
Anonymous
Not applicable
Author

I dont think it works, because the file name is defined in the tFileFetch component (property "destination Filename"), it is not fetched directly from the URI....
I would have be nice if this "destination filename" property was not mandatory, so the file extension would have been fetched from the URI...
Regards
Anonymous
Not applicable
Author

Hi,
You can create an arborescence depending on your URI (checkbox). I don't know if your URIs have different arborescence, but if not you could use it to get the name of the file. Furthermore I don't know how your job is designed, but you could also try to put your URI in a context variable and use this context to get what you want. Can you post a screenshot of your job?
Anonymous
Not applicable
Author

Try to fetch for example : http://gallica.bnf.fr/ark:/12148/btv1b22002053/f2.thumbnail
and automatically find out its extension (.jpg ? .gif ? .pdf ?)....
Regards
Anonymous
Not applicable
Author

How do you get your URI? If your URI comes from a context variable, it's quite simple to get the extension by using row.substring(context.myvariable.lastIndexOf('.')).
Anonymous
Not applicable
Author

Hi,
This is not as easy as it might seem in my opinion. Having a URI with an extension like .jsp doesn't mean the file you receive is of type jsp (whatever that may be), it could as well be an image that is send back. (How should the job know that the URI " https://community.talend.com/t5/Design-and-Development/tfilefetch-and-file-extension/td-p/115056" returns an HTML page for example?)
I don't know how to solve this, it's just that I don't think just looking for a . in a URI is enough to really solve this problem.
Maybe interpretation of the retrieved content is necessary to determine content type and therefor a possible extension, I don't know...
Best regards,
Arno
Anonymous
Not applicable
Author

Hi,
Obviously it depends on what you are looking for. So what's the use of the job, It will help.