I'm having content which encoded in base 64 format already. I want to set content in Mimemessage in object as if the content is in base64 format. Is there any method available for this? Please provide solution.
http://javamail.kenai.com/nonav/javadocs/javax/mail/internet/PreencodedMimeBodyPart.html
Related
I am making a audio player using
<audio src={audioSrc}>
tag.
When I get the audio file, it was a binary file(blob below) so I created a blob with it.
let test = new Blob(blob, {type: 'audio/mp3'};
And then created an object url
let objUrl = URL.createObjectURL(test);
This objUrl looks like blob:https://xxxxx and when I pass this string to <audio src={objUrl}/>, I cannot hear anything.
I was wondering if I have to convert this url to make it available in audio tag.
Can I get an advice for this problem please?
The first parameter of the Blob constructor is an array. MDN describes it like this:
An Array of ArrayBuffer, ArrayBufferView, Blob, USVString objects, or a mix of any of such objects, that will be put inside the Blob. USVString objects are encoded as UTF-8.
https://developer.mozilla.org/en-US/docs/Web/API/Blob/Blob#parameters
Maybe creating your blob like this already solves the problem:
let test = new Blob([ blob ], { type: 'audio/mp3' });
Another problem I could think of is that the binary data has a different mimeType other than 'audio/mp3' which could cause the audio element to give up decoding the data.
Just add another prop autoplay
<audio src={URL.createObjectURL(test)} autoplay/>
How do we decode $content?
My content:
When I simply do this:
I get this:
I've also tried this:
body('Get_blob_content')['$content']
that didn't work either:
another attempt:
base64ToString(body('Get_blob_content')['$content']):
How do we decode $content?
I agree with George Chen, the solution is decodeBase64(body('Get_blob_content')), but you check if the content is a valid json in String format, if not, try to add string function:
decodeBase64(string(body('Get_blob_content'))).
Regards.
How to find the file type whether it is an image or ppt or pdf from Base64 string.
How can i decode that string and also get the file extension of Base64 String.
It should be in AngularJs.
If the string was obtained by FileReader.readAsDataURL() (see https://developer.mozilla.org/en-US/docs/Web/API/FileReader/readAsDataURL) it should be similar to this one:
"data:image/jpeg;base64,/9j/4AAQSkZJRgABAgAAAQABAAD/2wBDAAgGBgcGBQg ... "
So the first part is the MIME_TYPE (data:image/jpeg;), then there's a delimitator (base64,) and finally the base64 string which can be decoded using a library like this one:
https://github.com/ninjatronic/angular-base64
I am a new guy for JSON, I don't know to send JSON object and Array...
But, I pass the JSON values like the below format,
object.put("code", "1");
object.put("message", "Success");
object.put("Name", "xxx");
object.put("F_Name","yyy");
object.put("Address", "zzz");
object.put("Phone_No","123");
out.println(object);
But it display like
{"Phone_No":"123","message":"Success","Address":"zzz","Name":"xxx","F_Name":"yyy","code":"1"}
I don't know, why it's display like this. How to order this? Please help me.
And this is what format, Array format or object format...
And tell how to send array values in JSON..
Thanks in advance..
You didn't write what is the class of the object. However, if you care about the order, use GSON and its JsonObject class:
import com.google.gson.Gson;
import com.google.gson.JsonObject;
JsonObject object = new JsonObject();
object.addProperty("code", "1");
object.addProperty("message", "success");
object.addProperty("Name", "xxx");
// ...
Gson gson = new Gson();
out.println(gson.toJson(object));
As my understanding of question and the code above, The "object" you already using might be json object. Usually JSON object can maintain data in the form of key, value pairs. So you are putting content into json object and displaying. That's why its getting displayed like that. The displayed format is json format. If you want to put array into json object you can put as you already did for normal strings.
object.put("array1", arrayvariable1[]);
object.put("array2", arrayvariable2[]);
I guess it might have helped you.
I'm using JasperReports to generate PDFs, and it gives me the PDF as a byte array, byte[].
I want to pass the raw bytes to another function that needs the file in terms of a FileItem object. In particular, the FileItem is from the Apache Commons library org.apache.commons.fileupload.FileItem.
// the function I want to pass it into
public DocumentDO toDocumentDO(FileItem fileItem);
Is there any way to do that or is it not possible (ie. the byte[] doesn't contain the metadata needed for it to be a FileItem like filename, mime type, etc)?
Your byte array is just what it is - bunch ow raw bytes, all meta data that you mentioned needs to be provided separately unless you read it into the file and then parse the file for the embedded meta information