We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to download image using hyperlinks in JSON file?

Introduction

This document explains the steps involved in downloading images using hyperlinks available in JSON file.

Objective

To create a workflow to parse JSON file and to download images using parsed hyperlink value.

List of processors used in workflow

Processors

Description

GetFile

Creates Flowfile from given file in the directory.

SplitJson

Splits JSON array element into multiple Flowfiles.

EvaluateJsonPath

Evaluates JSON and resultants value will be assigned to the given attribute.

InvokeHTTP

Gets response as Flowfile using given image URL.

UpdateAttribute

Gets filename with extension using expression language support.

PutFile

Stores Flowfile content into the given output directory.

 

Workflow overview

Steps involved in workflow

Step 1

Drag and drop the GetFile processor into canvas area.

Change the processor name with your convenient description.

In scheduling tab, select scheduling strategy and enter run schedule as your wish. Please refer to the following screenshot:

In properties tab, enter value for the Input Directory, File Filter and Keep Source File properties as mentioned in following screenshot:

 

The sample JSON file format used in this sample is

{

 "response": [

{"image": "https://cdn.syncfusion.com/content/images/products/data-integration/DIP-banner.jpg"},

{"image":"https://cdn.syncfusion.com/content/images/company-logos/Syncfusion_Logo_Image.png"},

{"image":"http://www.syncfusion.com/content/images/nuget/sync_logo_icon.png"}

           ]

}

Step 2

Drag and drop the SplitJson processor into canvas area. Connect the GetFile processor with the SplitJson processor with “Success” relationship. In properties tab, enter value for the JsonPath Expression as “response” (Need to enter JSON array. Please refer to the previous JSON file format) mentioned in following screenshot:

Note: To ignore the failure case, select the auto-terminate option for corresponding relationships. Please refer to the following screenshot:

Step 3:

Drag and drop the EvaluateJsonPath processor into canvas area. Connect the SplitJson processor with the EvaluateJsonPath processor with “split” relationship. In properties tab, select required option for the Destination property. Also add the new attribute “imagePath” and enter the expression language to get image path from JSON response as shown in the following screenshot:

Step 4

Drag and drop the InvokeHTTP processor into canvas area. Connect the EvaluateJsonPath processor with the InvokeHTTP processor with “matched” relationship. In properties tab, enter value for the required properties as shown in the following screenshot:

Step 5

Drag and drop the UpdateAttribute processor into canvas area. Connect the InvokeHTTP processor with the UpdateAttribute processor with “Response” relationship.  In properties tab, enter the required filename using the expression language for the newly added attribute “filename” as shown in the following screenshot:

Step 6

Drag and drop the PutFile processor into canvas area. Connect the UpdateAttribute processor with the PutFile processor with “success” relationship. Double click the processor to configure it. In settings tab, auto-terminate “failure” and “success” relationships and in properties tab, enter value for the required properties as shown in the following screenshot:

Step 7:

After the previous configurations have been done, start the workflow. It will generate resultant Flowfile as image file in the given output directory.

Article ID: Published Date: Last Revised Date: Platform: Control:
8578 03/14/2018 09/28/2018 Big Data Platform General
Did you find this information helpful?
Add Comment
You must log in to leave a comment

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon