Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Mail attachment (POST Req) without base64 encoding

GODAL TristanJul 8 2019 — edited Jul 8 2019

Hi. Do you know if there is a way to send an attachment (PDF File) into a POST request pointing on a SMTP server without encoding in base64 ? I make lot of search but I don't find a solution.

Currently, I'm using the Mailgun SMTP server to send my mail. I contact them about my problem (The file sent was corrupted) and they answer me that they actually encoding the attachment too when I send it to the server, so, you need to decode two times the files. Thing that the mail client doesn't do (It do it 1 time..). So, the only one solution I have is to convert my BLOB to a CLOB file without encoding, or to send directly the blob to the server.

So, I use this to send my attachment on the server :

|| '--' || lco_boundary || l_newline

    || 'Content-Type: application/pdf' || l\_newline

    || 'Content-Disposition: form-data; name="attachment"; filename="commande-koust.pdf"' || l\_newline

    || l\_newline

    || apex\_web\_service.blob2clobbase64(p\_attachment) || l\_newline

    || '--' || lco\_boundary || l\_newline

    || 'Content-Disposition: form-data; name="filename"' || l\_newline

    || l\_newline

    || 'pdf.pdf' || l\_newline

    || '--' || lco\_boundary || l\_newline

    || 'Content-Disposition: form-data; name="MAX\_FILE\_SIZE"' || l\_newline

    || l\_newline

    || '4000000' || l\_newline

    || '--' || lco\_boundary || '--';

As you can see, that's the classic way to send an attachment.

p_attachment is the BLOB file that I receive in my procedure.

The APEX code view require absolutely a clob file to be send. If I just try to insert "p_attachment" without "apex_web_service.blob2clobbase64()", I got an error that is :

Compilation failed,line 28 (06:49:27)

PLS-00306: wrong number or types of arguments in call to '||'Compilation failed,line 28 (06:49:27)

PL/SQL: Statement ignored

Maybe if you need, the discussion with Mailgun Support :

Capture.PNG

So I need finally to send clob file without encoding in base64. Do you have a solution? Thanks.

PS: Sorry for my english. I'm French

This post has been answered by cormaco on Jul 8 2019
Jump to Answer
Comments
Post Details
Added on Jul 8 2019
4 comments
837 views