How to convert the uploaded file in Box.com? - salesforce

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/

Related

How do I pass in an authorization header with the pdf url in react-pdf-highlighter?

I'm trying to use react-pdf-highlighter for highlighting certain fields on a pdf that were read by an OCR program. The current pdf view uses react-pdf which allows me to pass in an authorization header along with the url for the pdf. I'm not seeing the same option in the react-pdf-highlighter project, even though they both use Mozilla's PDF.js. Anyone know if there is a way to add headers for the pdf to be shown in react-pdf-highlighter?

dart: How to save a file?

I need to save the file that is on my hard drive.
File address: /home/mk/proj1/1.txt
Program address: /home/mk/proj2/
I try to save:
new dom.AnchorElement(href: '/home/mk/proj1/1.txt')
..setAttribute("download", '1.txt')
..click();
Displays information about saving, but writes: Failed! No file.
How to save a file?
There is not really a way to save a file in the browser (except perhaps limited support for temporary files)
You can search for JavaScript solutions. They will be quite similar for Dart in the browser.
For example JavaScript: Create and save file
If you want to store a file on the client machine, you can provide a download link.
See also How to force a Download File prompt instead of displaying it in-browser with HTML?
To provide a download link for data that is available in the browser clients code instead of a server file, you can use a data url.
See also https://stackoverflow.com/a/29691487/217408

Converting Blob object to html in google app

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.

How to create a file and make it downloadable in GWT?

I want to export the data in a celltable to a CSV file. I understand this must be done in the server side. I'm a bit lost on how to create a file, write the lines and then make the client download it.
One it's served, it could be downloaded automatically or by a "Download" button, is the same.
If you just want to generate file and serve it directly you can create a servlet and hit the servlet url in a Window, You may want to take the same datasource and use it at the server side to convert it into a csv. Please follow along the steps as described in (Download a generated pdf from client) and for downloading that from GWT Window follow (How to download a file via a button click i GWT?),

Getting images with HTTP Request in C

I am writing a program in C that acts like a proxy server in a Linux system: Client asks it for a web page,
it sends an HTTP GET Request to a distant server, and it gets the servers response (web page), which is saved in an .html file.
Here goes my problem: Most web sites got some references to images, so when i try to view the .html file proxy created, the images don't appear.
I have searched a lot, but found nothing..Is there a way to write some code to GET images too?
Thank you in advance
You're going to have to write code that parses the HTML file you get back and looks for image references (img tags), then queries the server for those image files. This is what web browsers are doing under the hood.
You have an additional problem though which is that the image references in the HTML file are to the original server. I'm assuming that since they don't load for you the server that returned the original HTML isn't available. In that case after you get each image file you will need to give it a name on the local filesystem and then alter the reference in the HTML (programmatically) to point to your new local image name.
So for example:
<img src='http://example.com/image1.png'>
would become
<img src='localImage1.png'>
If you're querying arbitrary websites then you'll also find that there are various other files you'll need to do the same with like CSS files and JavaScript files. In general its hard to mirror arbitrary web pages accurately - browsers have complex object models they use to interpret web pages because they have to deal with things like CSS and Javascript and you may need to be able to 'run' all that dynamic code to even be sure what files to download from the server (e.g. JavaScript including other JavaScript etc).

Resources