Skip to main content
Solved

Importing images to database text field ?

  • September 6, 2018
  • 4 replies
  • 92 views

lifalin2016
Supporter
Forum|alt.badge.img+38

Hi.

I have been assigned the task of importing 4000+ images from a remote service into a local Postgres database. An obvious FME task.

Fetching the images with ImageFetcher runs smoothly, but here starts my problems:

- I need to store the MIME type, but although ImageFetcher is set to auto-detect this, it never reveals it in the output. And no file extension is available, and no other transformer offers that service, so an improvement to ImageFetcher is warranted, I think.

- I need to store the image in a text column in base64 format, but a combination of GeometryExtractor (FME Binary) + TextEncoder (Base64) doesn't really seems to work.

The output should look like this: data:image/jpeg;base64,/9j/........

Is there a better way to accomplish my task ?

Cheers

Best answer by ebygomm

Have you looked at using a HTTPcaller instead, you can store the response body directly as binary then and the response headers can be stored in a list

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

4 replies

ebygomm
Influencer
Forum|alt.badge.img+44
  • Influencer
  • 3429 replies
  • Best Answer
  • September 6, 2018

Have you looked at using a HTTPcaller instead, you can store the response body directly as binary then and the response headers can be stored in a list


lifalin2016
Supporter
Forum|alt.badge.img+38
  • Author
  • Supporter
  • 592 replies
  • September 6, 2018

Have you looked at using a HTTPcaller instead, you can store the response body directly as binary then and the response headers can be stored in a list

Yeah, I got around to doing that. It seems like the only way.

 

Unfortunately, the output is still off, it seems, so maybe I'm still not getting the encoding right.

 

 


ebygomm
Influencer
Forum|alt.badge.img+44
  • Influencer
  • 3429 replies
  • September 6, 2018

HTTPcaller with response body as binary followed by a BinaryEncoder should get the encoding right, then you just need to construct the output with the data from the headers

image-to-base64.fmw


01011010
Contributor
Forum|alt.badge.img+4
  • Contributor
  • 5 replies
  • January 29, 2019

HTTPcaller with response body as binary followed by a BinaryEncoder should get the encoding right, then you just need to construct the output with the data from the headers

image-to-base64.fmw

Can you insert into a MS SQL table (VARBINARY(MAX)) using SQLExecutor? if so how did you do it?