Octet Stream Base64

Octet Stream Base64

Hi, There seems to be an issue with displaying attachments in the latest TB builds (Lanikai 3.1b2pre). An attachment with a content type header of. The following is an excerpt from RFC 4648 illustrating the Alphabet for Base64. The Encoding Process. The process to encode the input stream is fairly straightforward. A) The octet stream is read from left to right. B) Three 8-bit groups within the input stream is concatenated to form a 24-bit group. I am fetching a base64 image from my s3 bucket using the following code.The first fetch method returns an s3 presgined url. The fetch the presigned url and convert response to blob. When I check the response type it is an octet-stream. My question is how can I convert it to base64 image and display it in the img tag.

@Dai I think that if you are trying to base64 encode a stream that is large, maybe there is a better alternative than base64 encoding? I'm doing it to supply a file within a JSON web request, if there is a large file (MBs+), then it doesn't make sense for me to do that. – chris31389 Sep 17 '19 at 10:36. Octet bitstream; 0 1 2 3 4 5 6 7 8 9 A B C D E F; 00: 0: 1: 10: 11: 100: 101: 110: 111: 1000: 1001: 1010: 1011: 1101: 1101: 1110: 1111: 10: 10000: 10001: 10010: 10011.

Hi Guys,

Am back with another Article on How to Generate PDF files or Images out of Base64 content using DataWeave.

  • Anypoint Studio : 7.4 version
  • Mule Runtime : 4.2.2

As usual , DataWeave helps you to simply your process :)

Note: Please go through
Octet-stream base64
import * from dw::core::Binaries
Stream
from Mule Docs. These are very powerful!

Things To Remember:

1) Your Input for converting must be proper Base64 content. When i say proper , we cannot give some random Base64 . Even single letter change in Base64 will crash in opening the file! This is applicable for both PDF and Image files

2) For testing purpose , you can pass Base64 from postman by passing plain text.

3) Am writing the file on my Local to check whether its generated or not! Please use your local path for the same. I will be sharing code at the end! replace the file path with yours

Let's Get Started :

3 Simple Steps:

Generating PDF's

Step 1: Use below Transformation .

If you observe below DW , we have imported Binaries library so that the incoming Base64 encoded value is decoded to formData


Please note That parts , test (you can give any value) ,headers :Content-Type,content fields are mandatory to convert into pdf

Step 2: Keep Set Payload after Transformation and set MIME Type as application/pdf and content as #[payload]


Step 3 :You can write this into some file location as below with extension of file name .pdf

Octet


That's it , Run your end point by passing base 64 content and see the pdf is generated !

Generating Images

Step 1: Use below Transformation .

If you observe below DW , we have imported Binaries library so that the incoming Base64 encoded value is decoded to octet stream

Please note you can directly convert to octet-stream

Step 2: Keep Set Payload after Transformation and set MIME Type as image/jpeg and content as #[payload]

Step 3 :You can write this into some file location as below with extension of file name .jpeg

That's it , Run your end point by passing base 64 content and see the image is generated !

Pretty simple!! Buzz me for Base64 content for above example!

Try out !!

Octet-stream Base64

Happy Learning :)

Application/octet-stream Base64

Yours Sravan Lingam