Insert From URL Fails

I’m using the Insert From URL script step to grab images from a website. This script works fine if the image has an extension (e.g., .jpg). However, if the image does NOT have an extension, the script fails with a pop-up message, “connection failed.” Any suggestions on how to troubleshoot this?

Did you check in the OS logs ?

1 Like

Have you add header and trace in the curl option? You may see some information about the request.

3 Likes

This might seem a little convoluted, but you might be able to solve this using some cURL options:

$curl:

--output "the-file-name.jpg"
--FM-return-container-variable

Then insert into url targeting a variable instead of a field.

Insert from URL [ Select ; With dialog: Off ;
  Target: $container ;
  $url ;
  cURL options: $curl
] 

And finally, set your container field using Set Field. This uses a little Base64 trick to generate the content preview properly. But you can try setting your container directly without the base64 if you want.

Set Field [
  MyTable::containerField ;
  Base64Decode ( Base64Encode ( $container ) ; "the-file-name.jpg" ) 
] 

EDIT: the --output cURL option tells FM what to name the file, so you can add the extension back.

4 Likes

That's very odd. In my own experience, the only time I see that message is if the service itself isn't running.

Have you tried it using POSTMAN? Same results?

I would also try to replicate that in my own little REST service.

It sounds to me like a problem with the service and not with your code.

Can you post more details, like what Website?

1 Like

I resolved the download issue. Now I’ll need to export the file, add the .jpg extension, and re-import. This is required because the next step is to upload to my Wordpress website, which apparently requires the extension to display the image.

Hi @steverichter

I just want to call attention to the post above by @jwilling

For me personally, the technique he shows of using Set Field and a little trick with Base64Encode/Base64Decode has gone a long ways to accommodate having container data include its proper filename. If it works for you, it might be a trifle easier than an Export/Import, though I suppose neither is particularly difficult.

HTH,

-Steve

3 Likes

Update: I ended up using “Insert From URL” to load the “as is” image, “Export Field Contents” to add a .jpg extension, and then “Import Picture” to re-load the corrected file into the original container.

When I have more time, I’ll experiment with the method @jwilling proposed.

Thanks to all for your help.

2 Likes

Hey whatever works!

2 Likes