Processing TIFF Attachments in RingCentral using NodeJS - javascript

I have a program written in Node using the "RingCentral" package, the program downloads faxes sent to a RingCentral account. When the faxes are in PDF format everything works correctly, however if the fax attachment happens to be a TIFF image (only very few are) the data returned seems to be incomplete, it is always 390 bytes. Inspecting the file shows that it is indeed the TIFF image (starts with II*).
Has anyone come across this issue? Is there a way to force all faxes to be stored as PDF by RingCentral?
Thanks,
-Carlos

RingCentral supports storing faxes as PDF and TIFF files. The configuration preference is available per extension. Upon retrieval, the Content-Type HTTP response header will be set to application/pdf or image/tiff
You could check to see if the response header has "Content-Type" : 'image/tiff', so as to save the attachment as .tiff file format when you retrieve the faxes via the message-store endpoint :
GET /account/~/extension/~/message-store
For more information you could refer to our RingCentral-Fax-FAQ
For any support related issues, please open a case with our developer support at :
Portal : https://developer.ringcentral.com/support.html
Email : devsupport#ringcentral ( with the necessary details )

After rerunning my test again I realized these faxes are also having problems through the web interface, so the attachment must be corrupted for some reason.
Glad you found your issue and it was due to actual corrupted faxes in the comment thread. For others that come across this, here's some information on how to test TIFF files.
if the fax attachment happens to be a TIFF image (only very few are) the data returned seems to be incomplete, it is always 390 bytes[...] Has anyone come across this issue?
Downloading TIFF images works fine for me using the RingCentral API. I used the fax_download.rb script in the community Ruby SDK. I used the fax_send.rb demo script to send the test_file.pdf included in the SDK to an extension configured for TIFF files and was able to download and read it as a 14538 byte TIFF file using the fax_download.rb script.
Resource links:
Ruby SDK
fax_send.rb
fax_download.rb
test_file.pdf
Is there a way to force all faxes to be stored as PDF by RingCentral?
There is a file type configuration setting for PDF and TIFF per extension as mentioned by #CarpeDiem above. Having all extensions configured for PDF would ensure all stored faxes were in PDF format. This can be set by RingCentral support on the backend, but I'm not sure if there is a customer facing setting.

Related

Workaround to download files larger than 50MB using Google Script [duplicate]

I'm running URLFetchApp Requests to an Amazon S3 Server to pull Audio Files and relocate them to Google Drive. The HTTPResponse comes back in XML format.
I run the following code to convert into a workable blob that can be stored in Google Drive:
/*driveAppFolder, fileName, response are pre-defined variables from earlier in the program*/
var responseBlob = response.getBlob();
var driveAppFile = driveAppFolder.createFile(blob).setName(fileName);
This code works flawlessly up to a certain size. I haven't figured out the limitation yet, but I know a 50MB file (52657324 bytes) will prevent the blob from generating with the error:
InternalError: Array length 52389150 exceeds supported capacity limit.
I realize a similar JavaScript error was handled here, but I am locked in the confines of Google Apps Script currently. Is there a way I can work around this sort of limitation and get the blob made?
How about this answer? 50 MB is 52,428,800 bytes. At Google Apps Script, there are the limitation of the size of blob. The maxmum size is 52,428,800 bytes. So in your situation, such error occurs. In your situation, you download such large file. When you download it, how about using the following methods?
Use partial download by range.
Use a library for downloading large files from URL.
This library uses the partial download.
References:
Partial download
Sample script of partial download
Library for downloading large files from URL

Chrome Network Error - Downloading PDF

In our application, we have a users downloading PDF through a AJAX call -- basically we have a table listing a lot of PDF files and when the user clicks on a filename, an AJAX call is made to a Servlet which serves the file as reponse.
The Content-Length is set for the response along with other required params (Content-Disposition, Content-Type etc). We have observed that for a specific set of users, the download fails with a Network Error. The download is initially initiated and begins but after some time the download just stops processing and this error is thrown. This has been the behavior with both IE and Chrome.
Initially, the content-length was not provided and hence defaulted to chunked transfer but this has been changed now. Even with chunked transfer we did have the same issue.
We have run through the steps provided in Chrome documentation (clearing cookies etc) but there has been no respite. We did run through the net-exports feature in Chrome and they have the following as the last few lines as -
t=237104 [st=161960] DOWNLOAD_ITEM_INTERRUPTED
--> bytes_so_far = "0"
--> interrupt_reason = "NETWORK_FAILED"
t=237104 [st=161960] -DOWNLOAD_ITEM_ACTIVE
The users who are unable to download are able to download PDF from other sites. If we host a static PDF in our site, the users are able to access it as well.
Any pointers on what would need to be our next lookout?
(The users connect to a web server Apache HTTPD)
Thanks,
Aravind
I had the Network Error issue while downloading the PDF files from Jasper.
I followed the below steps to fix the downloading issue with the Chrome.
Enter the chrome://settings/content/pdfDocuments?search=pdf into the
address bar of the Chrome.
Turn ON the option "Download PDF files instead of automatically opening them in Chrome"
Change PDF MIME Type in Web Server or Response Headers from application/pdf to application/octet-stream
This problem is when is enabled gzip compression and/or HTTP/2
Enable http/2 for SSL connections is a hugely valuable performance setting. However http2 expects the reported size to match what the webserver reports for streamed content.
The problem occurs in Cloudflare to.

File API returns "invalid/octet-stream" for pdf file in Firefox

I'm doing file upload which checks file mime type in browser. It's uses jQuery File Upload Plugin and works good everywhere except one user.
For some reason file.type (html5 file api) returns "invalid/octet-stream" for pdf file (usually it's "application/pdf"). Pdf file is simple and can be opened at this pc without any problems.
Environment: Windows 7 and Firefox 40. Not reproduced in chrome or explorer.
Try deleting (or renaming/moving, for testing purposes) the file MimeTypes.rdf in the affected Firefox's profile folder.
(Under Windows this can usually be found under a path similar to c:\Users\[name]\AppData\Roaming\Mozilla\Firefox\Profiles\[some id].default - or just search for "MimeTypes.rdf".)
If the PDF upload works afterwards, you encountered a Firefox bug that was first reported in 2007 (basically the same here, reported in 2006). In a nutshell, any web site from which the user ever downloads a file has the potential to corrupt the MimeTypes.rdf file in regards to the extension of the downloaded file - maliciously or accidentally/unknowingly.
Things you can do:
Vote for the Firefox bug!
Quick fix to get it working for the one user right now: Have the user delete their MimeTypes.rdf file. Firefox will create a new, "fresh" one at the next start, but this will clear all MIME type / application associations that the user has created over time. Also, this will only help until the user downloads the next PDF file from some other web site that corrupts the MimeTypes.rdf file again.
Use the "user agent" header to determine if the file is uploaded from Firefox. If so and the MIME type doesn't match anything you wish to accept, double-check the file name's extension and accept the file anyway if the extension matches your accepted file type(s) (".pdf" in your case).

Hope to create gmail attachment preview like functionality using angularjs

I have a requirement where I want to show the file preview to the users.
There are various file types which are supported like; .pdf, .xlsx, .doc, .rar, .jpeg, .png and many more.
When user clicks on the preview it should open the file in popup where preview of the file is shown to him. User can Zoom-in, Zoom-out, Download the file. Just as you can see into gmail for attachment preview.
Please, can anyone guide me to any relevant library or helpful resource for the same.
Thanks in advance
There are two main ways you can do this.
1) Server-side: Render previews once server-side (on file upload) into jpg/png images, and store the previews on the server. This is the easiest to implement on the client side, but requires extra storage on the server.
2) Client-side: Render the previews 'live' with javascript in browser, this reduces the amount the server has to do/store, but does require the client to fully download the file in-memory before it can render the preview, which for large files could be an issue. Also, you would need javascript libraries included for likely each individual file type, since most libraries will target one specific file format.
Server-Side is probably the recommended way to go. What are you using for your web server?
You are looking at creating document viewer.
Belive me its big work as browser does not understand these formats. Browser can render images directly on canvas but it does not know how to render the other files. So, any file other than image formats, one need to save them temporarily on server and then stream on the browser and show them using the respective file viewer.
You can convert doc and xlsx files to pdf and show these files using pdf viewer (http://ngmodules.org/modules/ng-pdfviewer). There are plenty of document converters available on internet (however you will need to check the licensing terms as most of them are GPL licensed, hense can not be used in commercial projects).
If you want to save this work then go for third party server those take all paint to convert documents in html5 such as https://crocodoc.com/why-crocodoc/
You can also try using google doc viewer google doc veiwer
This question is fairly broad. I'm not going through all the steps of how to implement an attachment viewer directive, but here are some pointers you might find useful.
To allow the user to download the file, you simply put a download link somewhere. If you are hosting the attachment on Amazon S3, Google Cloud Storage or some other cloud storage service, check their documentation. If you're downloading the files from your own server, make sure to set the Content-Disposition HTTP response header to attachment; filename="ORIGINAL_FILENAME", where ORIGINAL_FILENAME is the file name you want to user to see in the save dialog that appears when they click the download link.
Now on to the viewer.
For PDF files, I'd use pdfJS. There's an angular directive for it here.
You could look at something like CloudConvert for other files, to convert ehm to a PDF, and then displaying them in pdfJS, but then you probably want to store the PDF on your server as well, in addition to the original files, which requires extra storage. You might also be able to use the Google Docs viewer, or Office 365 viewer, as described in this answer.

how to open csv file in IE in by javascript

In my asp page, I have to open a csv file in IE by java script. The code which I am using is as below:
csvWindow = window.open("/com/csv/"+csvFileName, "datacsv", "toolbar=yes,location=no,directories=yes,status=no,menubar=yes,scrollbars=yes,resizable=yes,width=790,height=450,screenX=50,screenY=25,left=50,top=25");
Code is running in IIS server.
When I run this code and open csv file it gives below message
Microsoft Office Excel cannot access the file
"http://192.168.3.228:107/com/csv/CSV_file_1345728.csv". There are several possible reasons:
The file name or path does not exist
the file is being used by another program
the workbook you are trying yo save has the same name as a currently open workbook.
But file is being created.So path is correct and i think that file is also not used by another program
Please help me what should I do
The problem is that when Excel is opened it will attempt to fetch the CSV file itself, this a change in behaviour in office apps since 2007. However since Excel runs in a different process it will not send any cookies that would have been generated during the logon. When the website receives the request it will respond with a 401 status.
There are no easy solutions that I know of with entirely satisfactory results. Here are a number of solutions but all have drawbacks.
Make the authentication cookie persistent, this will allow Offices apps to pick up and send the cookie. The down side being the user remains persistently logged even after a client machine reboot (much like how Stackoverflow appears to work).
Use a standard HTTP authentication protocol like "Basic" or "Negotiate". The down side is that this will cause Excel to display a logon box and the user has to logon again. One exception to this drawback is using "Negotiate" or "NTLM" against an IIS box where the site is registered as part of the IE's Intranet Zone, in which case the HTTP stack used by excel will attempt to use the current user credentials.
Have a server side script that can run anonymously send the csv file and include in the URL some unique ID (such as GUID) which is a one off grant of access. Much more complex to set up.
If you want to open the file with MS Excel, you could try not to serve the file directly, but write an ASP page with Content-Type=application/force-download, the real file name ending with .css and the actual file content. In this case, MSIE will first download the file to the local disk cache and then will feed it to MS Excel.
If you just want to show the CSV text in the browser window, maybe the best is to change its extension or to make some proxy page with Content-Type=text/plain and no mention of CSV at all. The association CSV/Excel seems to be hardcoded in MSIE.

Categories

Resources