I am working with an application that uses Aura component to Record Audio with navigator.mediaDevices functionality; the component allows me to record audio and save it in "audio/webm; codecs=opus" with a Blob format, but I am looking for a way to change the audio format to .mp3 or .ogg since I have to send it to another system that does not allow the .webm format.
Note: firefox supports .ogg format but chrome doesn't, only .webm
Is there any way to be able to change the format either by the client or the server side?
Related
I am trying save some video in react native app privately. So that i can download videos within app and can watch within app after download. So i am not able to get it how can i do this. Let me know if anybody have resolution for this approach. i was checking that we can convert files into byte than can store within react native app. again then convert into video and can watch it within app. Let me know if this can be done by anyone. Thanks
<Video source={{uri: "background"}}
ref={(ref) => {
this.player = ref
}}
onBuffer={this.onBuffer}
onError={this.videoError}
style={styles.backgroundVideo} />
Watch this video
You can watch the above video. Anybody have a idea that how mx doing this thing. I want to do same. Download videos and save and will be private and play in my app.
For downloading any file like video,img ..
there are two best known libraries for downloading files
https://www.npmjs.com/package/react-native-fs
https://www.npmjs.com/package/react-native-fetch-blob
Now you can follow their documentation to download files like Videos,images or whatever you want to your user's phone.
For the part that you dont want it to be available to user via gallery.
For this you can use react-native-fetchblob as it has builtin intent actions and views. You can download a video file with any random name like 1234CACHE any random name without any extension to it, specially dont give it extension like video.mp4 because gallery detects .mp4 files so dont give it any extension and the file won't be available in any gallery.
Now how to hide the file? react-native-fetch-blob allow us to save files into directories that are not publicly available i mean user cannot reach those directory and these directories are used only for saving App's data so you can save your video file in one of these directories.
Now after completing your download, You can open your file with the Intent.
Example:
const VIDEO_PATH = res.path() //the path where your downloaded video is saved, you will actually receive this in the response of download function.
const MIME_TYPE = "video/mp4"
//Now finally call the intent with video mime so the video will be opened in user's media player, or if you want your own media player you can use any library for that.
android.actionViewIntent(VIDEO_PATH , MIME_TYPE)
you can use https://github.com/RonRadtke/react-native-blob-util to download any remote files
I want to invoke the file save as prompt while allowing the user to download a file in ExtJS from a URL.
Basically the idea is to allow the user to change the file name and select his desired location before saving the file on their machine.
Is there any way I could do this?
I do not want to use:
A server side code to send the headers.
Nor do I want to use the Flash-based Downloadify library to do this.
Also, <a> tag's "download" attribute does download the file, but it does not prompt the dialog box if the browser settings are not set right.
Is there any way apart from the above where we could handle the file download in our application?
No, it cannot be done with javascript alone due to the security restrictions of the contemporary browsers. You can read files but I have no knowledge of a way to save files directly from the javascript alone.
If your "I do not want tos" are not that strict, here you can find an example of file downloading. The essence is to send "Content-Disposition: attachment" header.
https://salesforce.stackexchange.com/questions/45823/how-to-download-uploaded-file-in-box-com/46515#46515
In the above link the code will give an url (in the response) to download the file. But i want the file to be downloaded in HTML format. As per the box.com website i.e., https://developers.box.com/view/ they have given that we can convert the files to HTML. How can i do this using salesforce.
#Srilakshmi B S
If you want to download the file as HTML, you'll have to take the file and send it to the Box View service/API for conversion. The Box content API doesn't by itself allow you to convert documents for preview and download into HTML. That means that you'll need two separate tokens if using both API endpoint. If you are in fact planning to use both, there's some documentation here on how:
https://developers.box.com/using-the-view-api-with-the-content-api/
I have stored user uploaded document (.doc ,.pdf) as a Blob object into data-store.
Instead of allowing user to download the document, I would like to present it as an HTML page
for viewing the doc. how do I convert Blob into HTML ? does google app engine provides any ready made API for the same?
There is no ready made API in AppEngine to convert .doc or .pdf (or or other types of) files to HTML. You would need to find a library for your preferred language to parse the blob file into its parts structured as an object model (like a DOM). Then you would need to write code to convert individual parts of the object model to HTML, unless you are lucky enough to find another library. And no, StackOverflow is not a good place to ask "what library is there...".
No. AppEngine itself does not provide any file format conversion tools. You might want to look into Google Drive API, which might, to some extent, do the format conversion for you.
You can have embed a PDF reader on a web page by using pdf.js.
Most browsers already have a built-in PDF viewer. If you provide a link to a PDF file, when users click on it, many browsers will automatically display the document. Those browsers that do not support this option, will offer a user to download the file to their hard-drive.
This is the easiest solution - you don't have to do anything at all.
The only way I know to take the contents of a local file and push those bytes to a server is to set up a form post with an <input> of appropriate type to prompt the user to select a file.
I would like to do the same thing only pushing the data through XMLHttpRequest (no cross-scripting tricks).
Currently, we do this with an iframe to get the post behavior.
My sense is the iframe is the only solution, but I post here in case I've missed something.
You could use the JavaScript File API (available in Firefox 3.6 or later and latest versions of Chrome and Safari). Basically, you can add an event listener to the <input> tag that will fire when a user selects a file. Then, you can upload it using an XMLHttpRequest. Also, the File API can allow you to do other fancy stuff, such as drag-and-drop uploads, getting information about a file before it is sent to the server, and providing a progress bar as a file is uploading.More info: https://developer.mozilla.org/en/using_files_from_web_applications
This is not a good cross-browser solution because it doesn't have good support in all the popular browsers (Internet Explorer), but you could use feature detection in JavaScript to detect if the File API is available and revert back to your iframe method if it is not.