How can I download a .webarchive with ASIHTTPRequest? - iphone

I was just wondering how I can download a .webarchive from my UIWebView using ASIHTTPRequest. I've looked at their documentation but unfortunately, it doesn't mention anything about saving web archives.
I noticed that this app saves .webarchives to the iOS device and loads them.

To quote http://en.wikipedia.org/wiki/Webarchive :
"The webarchive format is a concatenation of source files with
filenames saved in the binary plist format using NSKeyedEncoder"
As jbat100 mentions, the ASIWebPageRequest code is likely to be a useful starting point - you'll need to write code to do the saving of the files into the binary plist format yourself.

Related

Can I upload already-encoded content to azure media services, instead of uploading a video and then encoding it? How?

I want to encode locally and upload to avoid spending money in encoding.
Is this allowed? I did not find any documentation on it.
When I simply uploaded a file to the storage, the media services account said it could not play it without the ISM file. I had to encode (was it re-encode? it was an mp4) the file I had uploaded - I want to avoid that.
Yes, absolutely allowed and encouraged for customers. Especially ones that have custom encoding requirements that we may not support.
You can upload an .ism file that you create along with your encoded files. It's a simple SMIL 2.0 format XML file that points to the source files used.
It's a bit hard to find searching the docs, but there is a section outlining the workflow here - https://learn.microsoft.com/en-us/azure/media-services/latest/encode-dynamic-packaging-concept#on-demand-streaming-workflow
There is also a .NET Sample showing how to do it here:
https://github.com/Azure-Samples/media-services-v3-dotnet/tree/main/Streaming/StreamExistingMp4
You can see the code line at 111 that shows how to generate the .ism file -
// Generate the Server manifest for streaming .ism file.
// This file is a simple SMIL 2.0 file format schema that includes references to the uploaded MP4 files in the XML.
var manifestsList = await AssetUtils.CreateServerManifestsAsync(client, config.ResourceGroup, config.AccountName, inputAsset, locator);

Failed to display UIWebView to display docx/xlsx file with SFUZipEndOfCentralDirectoryError error with custom URL

We are writing some program to display documents on iOS. I think that there are a lot of confusion on the web about what type of documents which iOS UIWebView could display. Generally people refer to Technical Q&A QA1630 Using UIWebView to display select document types to see that all the MS office 07+ files (such as docx, xlsx, pptx) could not be displayed, however actually that is not what we see from testing. Actually we are able to display docx/xlsx/pptx document at UIWebView either loading from a remote URL, local file or in memory (loadData, here the baseURL can not be nil on simulator, see this link). Of course We are testing on latest version of iOS on iPhone simulator, it might be that the support was not at older iOS. At this point, We don't know that yet. If you know, please let me know.
However right now, We have one issue to display document at UIWebView by using custom URL for security reason. I did the custom URL by following the code here: protecting iOS resource. We could display xls, doc, ppt, pdf file, but not docx/xlsx/pptx, We got some error like this:
EXCEPTION SFUZipEndOfCentralDirectoryError: Could not find the end of central directory record
We tried to debug and could not figure what's to do here. Do you see similar error here? Could anyone shed some lights on this? Thanks very much.
It looks like the document you're trying to open might be corrupt. docx, xlsx, and pptx files are actually zip files containing a bunch of XML documents and other data. Check if you are able to uncompress the file on your computer by renaming it to .zip and then unzipping.

Download and unpack a *.tgz file to a subdirectory of the Documents directory

There very well may be an answer to this already on SO, but I'm not familiar enough with compression formats to know if they're applicable to my case. So here's what I need:
1) Download a *.tgz file that is greater than 200MB.
2) Unpack it to a specified subdirectory of the Documents folder.
I know how to make the connection and begin downloading. But how do I download to an actual file (rather than storing it in memory), and once this download is complete how do I unpack it to my desired location?
To save the downloaded data to a file, see this SO-question and answer(s): The easiest way to write NSData to a file
To uncompress .tgz-files, see this question and answer(s): "Untar" file on iPhone
To download large files, see this question and answer(s): How to download large files using objective c on iphone
(Google is an awesome tool, really.)
Just as a sidenote, an app shouldn't download 200MB of data. It is time- and bandwith consuming and may cause Apple to reject your app.
Forget NSURLConnection; use ASIHTTPConnection (google it) which has an easy save to file option. (And resumes failed downloads too)
I don't know the answer to tar/gzip. My application uses zips instead and http://code.google.com/p/ziparchive/wiki/PageName does the trick.

xlsx database ios

I'm writing an iphone application that pulls xlsx file from the server, manipulates with it (reading and writing to it) and upload it to the server. So I need to convert it to plist format, do some operations with plist and convert plist back to xlsx and upload it to server.
How the convertion xlsx->plist and plist->xlsx could be done on ios?
Here's what you will need to achieve your task:
Note: You must do the heavy lifting
To parse an xlsx, you will need to understand the Open XML file formats: Link
To parse a plist, you will need to understand the Property List file format: Link
To parse, I recommend using the NSXMLParser: Link

how to creating localizable.strings file by code in iPhone

I am working on one multilanguage project which will download string from server depend on language selected by user. I would like to save this downloaded string into localizable.string file. So how could I do that? I know how genstrings works but I would like to generated *.strings file by code and save it. My code will read this *.strings file for localizable. Anybody know which api i have to use?
thanks in advance
Manu
Typically, localization depends on strings files that are within the app bundle. Since you can not modify the app bundle at run time, you will have to put the strings files you downlaod elsewhere and you will have to modify the usual localization methods to find and use those strings files.
Look at Apple's iPhone samples to see how they do localization and fetching of the strings, and see if you can replace all the local accesses of the localization resources with resources in another directory.