{ Community }
  • Academy
  • Docs
  • Developers
  • Resources
    • Community Articles
    • Apigee on GitHub
    • Code Samples
    • Videos & eBooks
    • Accelerator Methodology
  • Support
  • Ask a Question
  • Spaces
    • Product Announcements
    • General
    • Edge/API Management
    • Developer Portal (Drupal-based)
    • Developer Portal (Integrated)
    • API Design
    • APIM on Istio
    • Extensions
    • Business of APIs
    • Academy/Certification
    • Adapter for Envoy
    • Analytics
    • Events
    • Hybrid
    • Integration (AWS, PCF, Etc.)
    • Microgateway
    • Monetization
    • Private Cloud Deployment
    • 日本語コミュニティ
    • Insights
    • IoT Apigee Link
    • BaaS/Usergrid
    • BaaS Transition/Migration
    • Apigee-127
    • New Customers
    • Topics
    • Questions
    • Articles
    • Ideas
    • Leaderboard
    • Badges
  • Log in
  • Sign up

Get answers, ideas, and support from the Apigee Community

  • Home /
  • Edge/API Management /
avatar image
0
Question by PiyushSharma · Mar 05, 2018 at 02:40 AM · 2.3k Views base64base64 encodeconvertpdf

Convert PDF stream to base64 string in APIGEE

Hi @Dino,

I am doing a multipart form-data POST to upload a pdf file to Amazon S3. We have a requirement to virus scan the PDF before sending to S3. There is a virus scan API which does the job but the pre-requisite to call the API is that the payload should be Base64 encoded.

Therefore, I need to convert the PDF file stream to Base64 encoded string in APIGEE.

I have seen a similar post with no solution in that (convert pdf stream to base64)

Would you be able to help me achieving this?

Comment
Add comment
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Close

2 Answers

  • Sort: 
avatar image
1

Answer by Dino   · Mar 29, 2018 at 05:45 PM

Hi Piyush

Yes, you can base64 encode an octet stream in Apigee Edge.

If I were doing this, I would want to do it in Python callout, or a Java callout, or a JS callout.

Here is a suitable Java callout that does this.

The configuration would look like this:

<JavaCallout name='Java-Base64Encode'>
  <Properties>
    <Property name='action'>encode</Property>
    <Property name='string-output'>true</Property>
  </Properties>
  <ClassName>com.google.apigee.edgecallouts.Base64</ClassName>
  <ResourceURL>java://edge-custom-base64-1.0.2.jar</ResourceURL>
</JavaCallout>

This will slurp in the request or response .content (depending on where you attach the policy) , and place an encoded form of it in "b64_result".

You can then use ServiceCallout to send that as a payload to the Virus scanner. And if that succeeds, then send the original request.content into S3.

Comment
Add comment Show 1 · Link
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image vinay · May 20, 2018 at 07:40 AM 0
Link

@dino : Can you let us know how do you post message for decode to work? the sample which is given works via online but wondering how to test the proxy for decode to work via apigee? It throws error - not Base64

avatar image
-2

Answer by Priyadarshi Ajitav Jena · Jan 12 at 12:20 PM

ref: https://stackoverflow.com/questions/13538832/convert-pdf-to-a-base64-encoded-string-in-javascript

Comment
Add comment Show 1 · Link
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Dino-at-Google ♦♦   · Jan 12 at 10:04 PM 0
Link

No, you won't be able to use that. The answer is as I provided 2 years ago. We don't need any other answers here. The original answer is still the right answer.

Follow this Question

Answers Answers and Comments

60 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Error with special character in password 4 Answers

How-To: Convert PDF binary stream to base64 string in Apigee 2 Answers

Does JsonThreatProtection & RegEx policy work for Base64 encoded payload? 1 Answer

Multiple Content Types in single request 1 Answer

How to check for XSS which is in base64 encoded format 1 Answer

  • Products
    • Edge - APIs
    • Insights - Big Data
    • Plans
  • Developers
    • Overview
    • Documentation
  • Resources
    • Overview
    • Blog
    • Apigee Institute
    • Academy
    • Documentation
  • Company
    • Overview
    • Press
    • Customers
    • Partners
    • Team
    • Events
    • Careers
    • Contact Us
  • Support
    • Support Overview
    • Documentation
    • Status
    • Edge Support Portal
    • Privacy Policy
    • Terms & Conditions
© 2021 Apigee Corp. All rights reserved. - Apigee Community Terms of Use - Powered by AnswerHub
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Create an article
  • Post an idea
  • Spaces
  • Product Announcements
  • General
  • Edge/API Management
  • Developer Portal (Drupal-based)
  • Developer Portal (Integrated)
  • API Design
  • APIM on Istio
  • Extensions
  • Business of APIs
  • Academy/Certification
  • Adapter for Envoy
  • Analytics
  • Events
  • Hybrid
  • Integration (AWS, PCF, Etc.)
  • Microgateway
  • Monetization
  • Private Cloud Deployment
  • 日本語コミュニティ
  • Insights
  • IoT Apigee Link
  • BaaS/Usergrid
  • BaaS Transition/Migration
  • Apigee-127
  • New Customers
  • Explore
  • Topics
  • Questions
  • Articles
  • Ideas
  • Badges