NSRangeException while opening local .doc files on webview - ios

I am trying to open a downloaded .doc file in UIWebview on iPad.
Basically .doc file have unicode character in both file name & file content which i am trying to open .
I got following error logs in console
WebKit discarded an uncaught exception in the webView:decidePolicyForNavigationAction:request:frame:decisionListener: delegate: <NSRangeException> *** -[NSArray objectAtIndex:]: index 0 beyond bounds for empty array
But neither webview's didFailLoadWithError or webViewDidFinishLoad delegate is called so how can i trap the error .What could be reason for it?

I've seen a few questions like this here before.
Such as:
Displaying ppt, doc, and xls in UIWebView doesn't work but pdf does
and
UIWebView does not open ms word (doc) and ms excel (xls) files
You might find some helpful hints in those questions.
Does the file open correctly when you download it on a Macintosh?
Is the mime type set correctly?
What else have you implemented in your UIWebViewDelegate?

Related

How to save breakpoints in Centura 6 Team Developer SQL/Windows

How can I save breakpoints in Gupta 6? When i refresh libraries after inserting some code into another .apt, my breakpoints in main program are lost. Is there any trick how to prevent from it?
Breakpoints will be saved if you save the file as TYPE binary ( i.e. save as file type = 'Normal' ) , not if saved as Text ( i.e. file type = 'TEXT' or 'INDENTED TEXT' ). This is regardless of what file extension you have . p.s. only save as binary if you're in debug mode. Otherwise difficult to fix if code becomes corrupt. If saved as Text - much easier to fix.

How can one display a downloaded file in a WebView?

I receive the path to a file that has been downloaded to the device. I try using <WebView source={{ uri }} /> to display the content: i.e. uri = '/Users/user/Library/Developer/CoreSimulator/Devices/1897591-5645-4C4F-A3CE-3DE4F7DD67C7/data/Containers/Data/Application/23485972-4B66-4DCF-8101-F419DF12CB87/Documents/RNFetchBlob_tmp/RNFetchBlobTmp_hhbjcw8zag7jqgra3mldkd'.
All I get is:
Error loading page
Domain: WebKitErrorDomain
Error Code: 102
Description: Frame load interrupted
Does WebView actually accepts files stored locally?
WebView for iOS can only open files by path that are stored in you project, not in your app’s file system unfortunately.
You can use webview to open base64encoded content of the file but passing it in the WebView url={base64encodedcontent}. Checkout this answer https://stackoverflow.com/a/41895475/4655003
You can also try something like this: https://github.com/wkh237/react-native-fetch-blob/wiki/iOS-API#iospreviewdocumentpathstring to use the native UIDocumentController to preview files.
RNFetchBlob.ios.previewDocument(pathToLocalFile)
I don't have the solution but it can help you:
Error Code: 102 occurs when webView:shouldStartLoadWithRequest:navigationType is returning NO (false).

Error in iOS: "you don't have permission"

I'm working on an iOS project in Swift which uses the Dropbox API to upload text files to Dropbox as well as load and read them from Dropbox. However, when I try to load a file using my DBRestClient using the following line:
restClient.loadFile("/data/" + yearStr + "/" + yearMonthStr + "/" + fullStr + ".txt", atRev: nil, intoPath: "temp2.txt")
I see the following error message in the console:
DropboxSDK: error making request to /1/files/sandbox/data/15/15_12/15_12_10.txt - (404) Path is a directory`
I'm not really sure what this means, since neither path involved in the call looks like a directory to me. I've searched for this error message but I can't seem to find it anywhere online, and I'm not sure what else might have caused it since commenting out this line prevents the error fro showing up and the same filepath works fine in other calls that don't involve loading files. Am I missing something about how loadFile() works?
UPDATE: I fixed the previous error by deleting a directory with the that filepath, making it choose the correct file. However, I am now getting the following error instead:
DropboxSDK: error making request to /1/files/sandbox/data/15/15_12/15_12_10.txt - (513) Error Domain=NSCocoaErrorDomain Code=513 "The file couldn’t be saved because you don’t have permission." UserInfo={path=/data/15/15_12/15_12_10.txt, destinationPath=temp2.txt}
I'm not sure what it means-- do I not have permission for the destination on my phone, or for the file on dropbox? I'm looking up this error message but I'm not finding anything yet, so help would be much appreciated.
According to the documentation, code 513 corresponds to:
NSFileWriteNoPermissionError = 513,
That seems to match the error message you get, and should be referring to the local destination path, which in your case is:
temp2.txt
You should check that you have access to write to that local path, and that it's a valid path, e.g., should it start with a '/'?. (Or moreover, perhaps you should be writing to NSTemporaryDirectory or something like that.)

How to print PDF file already opened in QLPreviewController using print button?

I get binary array then convert it and save in Documents folder and then showed in QLPreviewController. I have seen the right button on the tool bar of QLPreviewController.
I want to print that is in the preview right now. But when i tab error occurs
*** Assertion failure in -[UIDocumentInteractionController setURL:], /SourceCache/UIKit_Sim/UIKit-2380.17/UIDocumentInteractionController.m:960
Also please guide me about printing that document. I have read about UIPrintInteractionController.
Why this Error occurs because you have set the URL wrong.
You are setting url like that;
/Users/akrama2/Library/Application%20Support/iPhone%20Simulator/6.1/Applications/59356D13-C021-431F-A5D2-B8CD16E2B301/Documents/Application_Report.pdf
Where as UIDocumentationController task URL as:
file://localhost/Users/akrama2/Library/Application%20Support/iPhone%20Simulator/6.1/Applications/59356D13-C021-431F-A5D2-B8CD16E2B301/Documents/Application_Report.pdf
This minor mistake will made you mad ;)

Restler3- POST Upload (zip) Files

I really enjoy Restler3, but now there is a problem.
I want to POST a ZIP file to the server. Just by a simple HTML-Form.
To enable the upload if have to add
$restler->setSupportedFormats('UploadFormat');
But if do that all the JSON-GET-Requests just won't work.
Fatal error: Uncaught exception 'Luracast\Restler\RestException' with message 'UploadFormat is read only…
That's the error-message. What should I do to fix that?
I also had this problem. Changing my code to this worked:
$r->setSupportedFormats('UploadFormat','JsonFormat');

Resources