Upload images from module to api

Hi,

My situation

I am working on a custom application to upload image files to an api/service.

the images would likely be fetched from the Google Drive > Download file module and then uploaded with the custom module.

My issue

I am having trouble aligning the two.

the input data coming being given to my custom module looks like this:

[
    {
        "url": "/api-endpoint",
        "api_key": "a_key_here",
        "fileData": "IMTBuffer(289711,binary,3ebb4a3bcdaf537549):ffd8ffe00000000000000"
    }
]

and my custom application’s module json looks like this:

{
    "url": "https://api-url{{parameters.url}}",
    "method": "POST",
    "headers": {
        "X-Api-Key": "{{parameters.api_key}}"
    },
    "body": {
        "fields": [
            {
                "name": "image",
                "value": "{{parameters.fileData}}"
            }
        ]
    },
    "response": {
        "data": "{{body}}"
    }
}

my mappable params for the file data looks like this:

    {
        "name": "fileData",
        "type": "buffer",
        "label": "File Data",
        "required": true,
        "semantic": "file:data"
    }

Any suggestions? Thanks!

I’m not sure I understand your question. NOrmally, the fileData should be the bytes that compose the image, no? And if your module expects bytes of data and you give the bytes of data you received.… i’m a bit lost.

L

So I am trying to make a module that uploads images to a microservice, which will handle some logic there and send back a response, which is the converted/updated image.

The idea is that I would have a module from any common organization (Google Drive, CMS platforms, …) find the image, download it in the scenario and then send the image data to the service through the custom module.

The custom application I made is set and is able to communicate with the microservice. so the connection should be OK. But when I try this new module, I am not even getting to the request, it gives me an error saying “No image file provided”

This error comes from the module itself and not the microservice I think, because I could not find any request log being triggered on that side.

Here’s the JSON:

# the module's main JSON block (communications)

{
    "url": "https://microservice-endpoint{{parameters.url}}",
    "method": "POST",
    "headers": {
        "X-Api-Key": "{{parameters.api_key}}"
    },
    "body": {
        "image": "{{parameters.fileData}}"
    },
    "response": {
        "data": "{{body}}"
    }
}
# Mappable parameters JSON

[
    {
        "name": "api_key",
        "type": "text",
        "label": "Api key",
        "required": true
    },
    {
        "name": "url",
        "type": "select",
        "label": "Action",
        "required": true,
        "options": [
            {
                "label": "Convert to WebP",
                "value": "/convert/file/to/webp"
            },
            {
                "label": "Convert to PNG",
                "value": "/convert/file/to/png"
            },
            {
                "label": "Convert to JPG",
                "value": "/convert/file/to/jpg"
            }
        ]
    },
    {
        "name": "fileData",
        "type": "buffer",
        "label": "File Data", 
        "required": true,
        "semantic": "file:Data"
    }
]

Is there a better practice? or something I should change?

Is it possible to see screenshots of your flow and the configuration you are using in your modules? Are you developing a new module to use with Make? If that’s the case I can’t comment. I’ve never done that.

If it’s a regular automation module, then I’m not sure. The “No image file provided” error means your microservice is not getting the data or the filename or the URL or…

This, though, makes me think:

"fileData": "IMTBuffer(289711,binary,3ebb4a3bcdaf537549):ffd8ffe00000000000000"

This looks like information about a file or a pointer to a file in the database. If that’s what you’re sending to your microservice, it needs to know how to handle that information to get the image data. It doesn’t look like it can.

L

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.