Skip to main content
Solved

Importing images to database text field ?

  • September 6, 2018
  • 4 replies
  • 74 views

lifalin2016
Contributor
Forum|alt.badge.img+29

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

View original
Did this help you find an answer to your question?

4 replies

ebygomm
Influencer
Forum|alt.badge.img+39
  • Influencer
  • 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
Contributor
Forum|alt.badge.img+29
  • Author
  • Contributor
  • September 6, 2018
ebygomm wrote:

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+39
  • Influencer
  • 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+2
  • Contributor
  • January 29, 2019
ebygomm wrote:

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?


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings