0 votes

Is it possible to download pictures from for example contacts.picture using a json API request? I cannot find any documentation about this.

asked in SOAP by (219 points)
I planned some time tomorrow to investigate the streaming of images and PDF files, from the user interface. I'll include also the Remote API as a test

2 Answers

0 votes
Best answer

Here are some new topics regarding Efficy with pictures & PDF files.

Also some examples on how you can get the MIME64 and JSON encoded data for picture fields and files, without that special SQL function from the comments

To get the picture of a contact, use this request with includeblobcontent=true:

        "@name": "consult",
        "entity": "Cont",
        "key": 286,
        "@func": [
            {"@name": "master", "tableview":0, "includeblobcontent": true}
answered by (7.4k points)
selected by
Thanks Kristof!
0 votes

Hello, currently it is not supported to speficially download pictures via JSON api, however if you do a json consult request on that entity and specify the field you want, as it is a BLOB field actually, it is very probable that you will get a base64 representation of its data back.

answered by (449 points)
yes indeed :) because it's possible we might improve the young JSON api if something is missing and i'm curious to know about some use cases we might not have though of, but for what you describe indeed it's a direct solution with the /img request. It means that maybe we should add more info to the documentation of that request or extend its capabilities.
I'm trying to publish images to a Drupal website using OpenUrlSecure. Since I had issues with cookies I had to use a complete different approach where I was not able to use any Efficy scripting at all. For me the solution now is using a FME-script (https://www.safe.com/fme/fme-server/) where I retrieve pictures directly from the database (using the example from @svu) and convert it to a base64 string before publishing the data at the Drupal website. So I think it is more my lack of knowledge how to use the Efficy api properly instead of missing documentation. Although I also had issues with the efficy blob's and streamfiles several times before when building integrations with other applications.
Thanks for your help!
OK so your ideal scenario is logging in a drupal admin back end with openurlsecure, keep the cookie and retrieve a picture field, convert it to base64 and send it to drupal. Well for the cookies there might be some difficulties, but as for the rest it's straightforward, there is this encodeMime64Utf8 method (https://help.efficy.com/extras/serverjs.html#Library-encodeMime64Utf8) that allows you to take a TDataset.FieldByName('F_MYPIC').AsString and convert it to base64 without use of SQL or FME.
It seems to be possible according to Kristof: https://help.efficy.com/edn/projectguides/openurlsecure use case 5 and 6, but since my programming skills are less compared to my FME skills, I eventually went for FME
okay, thanks !
1,248 questions
1,517 answers
328 users