Page 1 of 1
In linux rest post example with basic authentication and base64 image in the body part
Posted: Wed Apr 05, 2023 1:43 pm
by LiK137
Hi,
I'd like to know whether it is possible from linux to post data to server with basic authentication to send data in base64 encoding using rest api. Unfortunately could not find purebasic example, only Java and C# for Windows implementations available in internet.
Re: In linux rest post example with basic authentication and base64 image in the body part
Posted: Wed Apr 05, 2023 1:45 pm
by infratec
viewtopic.php?p=521613#p521613
Code: Select all
*Auth = UTF8("User:Password")
If *Auth
Auth$ = Base64Encoder(*Auth, MemorySize(*Auth))
FreeMemory(*Auth)
EndIf
Header$ + "Authorization: Basic " + Auth$ + #CRLF$
Re: In linux rest post example with basic authentication and base64 image in the body part
Posted: Wed Apr 05, 2023 3:55 pm
by LiK137
Thank You very much for reply.
What if the Base64 encoded string length is greater than 65K, assume 10MB.
Should it work with SendNetworkString or SendNetworkData in one send or should it be separated and sent in loop until all data sent?
Re: In linux rest post example with basic authentication and base64 image in the body part
Posted: Wed Apr 05, 2023 7:11 pm
by infratec
Why does someone send a large file in base64
It is simply larger and has no benefits.
Re: In linux rest post example with basic authentication and base64 image in the body part
Posted: Thu Apr 06, 2023 8:11 am
by LiK137
What if in case large file? Sender doesn't care about size, just select photo by thumbview (Due to camera high quality issue size of images above 1 megabytes) and push the button. And question is whether the solution link You mentioned applicable to such bigger than 65K (usually 1-3 megabytes) files?
Re: In linux rest post example with basic authentication and base64 image in the body part
Posted: Thu Apr 06, 2023 4:42 pm
by infratec
You should be able to send large files. (I never tried it with PB, so simply give it a try)
But still: base64 is always 30% larger then the binary file.
Re: In linux rest post example with basic authentication and base64 image in the body part
Posted: Thu Apr 06, 2023 8:46 pm
by LiK137
Thank You very much for reply.
You mean it is possible sending large file in only one post without breaking into smaller parts in a loop?
Then what about TCP packet size limitation?