I want to show media files in my iOS files. The media file can be audio, video, pdf or doc file.
In JSON file I am getting base64 encoded data. According to its media type I wants to show in view or WebView.
How to achieve this?
I tried below code,
// NSData from the Base64 encoded str NSData *nsdataFromBase64String = [[NSData alloc] initWithBase64EncodedString:base64Encoded options:0]; NSLog(@"NSdata from base64: %@", nsdataFromBase64String);
but, in the output, I am getting a null value.
How to decode that base64 encoded data and how to show that media according to its type?
So I have an image cropper and its allowing the user to set the size of the image. The image returned after it is cropped is in this form:
However, when I try to decode this, i'm told that it is not in the correct format... What is going on here?
EDIT: I'm using
var base64 = require('base-64'); base64.decode(string);
EDIT: Full return value: https://pastebin.com/vsHBq3pR
I am using Gmail API to read emails from Gmail account.
In the body I am replacing some chars which are needed as I read in the forums:
String codedBody = body.Replace("-", "+"); codedBody = codedBody.Replace("_", "/");
Problem is that when I try to convert it
byte data = Convert.FromBase64String(codedBody);
there is an exception which is firing with some emails:
System.FormatException: 'The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.'
The string which is coming from the request is:
What is causing this problem?
Encoding is new to me in Python, and I am trying to understand it. Apologies if this has been asked and answered already.
I am trying to encode a Python list and decode it.When I am trying to encode a list directly, I am hitting an error like below.
>>> my_list = [1, 2, 3]>>> encoded_list = base64.b64encode(my_list)Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/base64.py", line 54, in b64encode encoded = binascii.b2a_base64(s)[:-1]TypeError: b2a_base64() argument 1 must be string or buffer, not list
To fix it, I converted the list object to a string and passed it to the encode function and I was able to successfully encode it.
>>> encoded_list = base64.b64encode(str(my_list))>>> encoded_list'WzEsIDIsIDNd'
When I try to decode it, I get a decoded string like below.
>>> decoded_list = base64.b64decode(encoded_list)>>> decoded_list'[1, 2, 3]'>>> type(decoded_list)<type 'str'>
But my original intention was to encode and decode a list and not convert the list to a string and then string to list.
Pretty sure this is not the right way to encode objects like dict or a list. If that's the case, Can someone please enlighten me on how to encode/decode non string objects in Python?
Thanks very much.
I am facing a major issue in encoding/decoding a base 64 image.
My purpose is to save a canvas image as base64 decoded string that can later be base64 encoded in php.
var string= canvas.toDataURL("image/jpeg");var abc = window.atob(string.split(","));var blob = "HEADERS"+abc;
blob is the file.
$Data = blob File$img = substr($Data, $start, $end);$img = base64_encode($img);
I start when I find chr(0xFF) . chr(0xD8) in the blob file and end when I find chr(0xFF) . chr(0xD9)