DataPower

DataPower

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
Expand all | Collapse all

Fetch a File from SFTP and convert to Base64

  • 1.  Fetch a File from SFTP and convert to Base64

    Posted Tue December 08, 2020 08:31 PM

    Hi ,

    I have requirement where i have fetch at .zip file from sftp server and convert it into a base 64 to call a backed .

    Also i am able fetch a file from sftp poller but stuck in how to convert in into base 64 .

    Kindly help

    Regards ,

    Mayur



    #DataPower
    #Support
    #SupportMigration


  • 2.  RE: Fetch a File from SFTP and convert to Base64

    Posted Wed December 09, 2020 11:21 AM

    Hi Team ,

    Does this feasible please confirm .

    Regards ,

    Mayur



    #DataPower
    #Support
    #SupportMigration


  • 3.  RE: Fetch a File from SFTP and convert to Base64

    Posted Mon December 14, 2020 05:49 AM

    Hi Team ,

    Is there any possible solution for requrirement 1 , also i able to fulfill 2nd requrirement .

    Kindly let us know .

    Requrirement 1:- pull a file from sftp ,convert to base64 and call a backend service .

    Requrirement 2:- pull a file from sftp and push to another sftp server

    <?xml version="1.0" encoding="UTF-8"?>

    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

    xmlns:dp="http://www.datapower.com/extensions"

    xmlns:regexp="http://exslt.org/regular-expressions" extension-element-prefixes="dp regexp"

    exclude-result-prefixes="dp regexp" version="1.0">

    <xsl:template match="/">

    <xsl:variable name="FrontsideFTP" select="dp:variable('var://service/URL-in')"/>

    <xsl:variable name="Filename" select="regexp:match($FrontsideFTP, '([^\/]*)$')"/>

    <xsl:variable name="Filename2" select="substring-before($Filename,'?Rename')"/>

    <xsl:variable name="BacksideFTP" select="concat('sftp://admin:Passxxxx/home/admin/File/FTP/',$Filename2)"/>

    <dp:set-variable name="'var://service/routing-url'" value="$BacksideFTP"/>

    <xsl:message dp:priority="debug">OId URL: <xsl:value-of select="$FrontsideFTP"/></xsl:message>

    <xsl:message dp:priority="debug">Filename: <xsl:value-of select="$Filename"/></xsl:message>

    <xsl:message dp:priority="debug">Filename2: <xsl:value-of select="$Filename2"/></xsl:message>

    <xsl:message dp:priority="debug">New URL: <xsl:value-of select="$BacksideFTP"/></xsl:message>

    <xsl:copy-of select ="*"/>

    <xsl:variable name="response">

    <dp:url-open target="{$BacksideFTP}" response="ignore" data-type="base-64">

    <xsl:copy-of select="Filename2"/>

    </dp:url-open>

    </xsl:variable>

    <xsl:message dp:priority="error">responseL: <xsl:value-of select="$response"/></xsl:message>

    <xsl:variable name="encdata" select="dp:binary-encode($Filename2)"/>

    <xsl:message dp:priority="error">encdata: <xsl:value-of select="$encdata"/></xsl:message>

    </xsl:template>

    </xsl:stylesheet>

    regards ,

    mayur



    #DataPower
    #Support
    #SupportMigration


  • 4.  RE: Fetch a File from SFTP and convert to Base64

    Posted Mon December 14, 2020 05:47 PM

    Hi,

    this has been discussed in another thread, please open just one thread per discussion topic.

    --HP



    #DataPower
    #Support
    #SupportMigration