WebFileUploader and .Pages files

I have a WebFileUploader with a filter that checks the file type to allow fileTypes of “.pages”.

Some people can upload fine to it, but others report a “this is a .zip file” error.

Oddly, some of the uploads show up as “.pages” files and some as “.zip” (and when I manually unzip them, they contain a .pages file)

I’m guessing that two things may be at play:

  • different versions of Pages app ?
  • different web browsers - perhaps Safari lies about it being a .pages file then uploads a .zip file, whereas other browsers don’t ?

Anyone know how this works?

Hmm, I guess some browsers might be confused…
A .pages file is actually a zip file. Rename it to have the .zip extension and you can unzip it and see its contents. Just like an .xlsx file.
Hmm, wierd.

iOS apps are similar. .ipa files are just zip files.

[quote=183981:@Michael Diehr]Some people can upload fine to it, but others report a “this is a .zip file” error.

Oddly, some of the uploads show up as “.pages” files and some as “.zip” (and when I manually unzip them, they contain a .pages file)[/quote]

Which browser ? Is it possible that in early versions Pages documents were bundles that browsers zip to enable upload ?

It works fine here with Safari, Chrome and FireFox…

So are .epub and Android .apk

The user reports “I figured out that newer versions of pages saves files that have pictures as .zip files. I was able to open on older version of pages that would save the file as .pages.” and the upload worked. Not clear what browser was being used.

I guess I possibly found the insect : Save a document as a package or a single file in Pages, Numbers, or Keynote on Mac - Apple Support

If your guy has enough pictures so the doc goes over 500 MB, Pages offers to save as package, which I believe could very well be bundle. If so, then the browser may automatically zip the file.

He may have used an awful lot of pictures to get to such a size, though. I tried shoving huge pictures in a doc, but Pages optimises them and I could never get to 500 MB.

I wonder if saving files as packages got to be too much of a pain? Saving files as zip makes file transfers much easier.

How do the apps use the renamed zip files? Are they reading and writing the zip format directly or unzipping somewhere and then zipping on save?

[quote=184157:@Hal Gumbert]I wonder if saving files as packages got to be too much of a pain? Saving files as zip makes file transfers much easier.

How do the apps use the renamed zip files? Are they reading and writing the zip format directly or unzipping somewhere and then zipping on save?[/quote]

I looked again at the page I linked to. It appears one can choose the file type (single file or package) in File/Advanced. I saved a file as package. Sure enough, it is simply a bundle with the .pages extension.

The zipping does not come from Pages, but from the browser.

Reading the Apple post, though, leads to think that some versions in the past saved only as packages. Maybe Michael’s customer is using an old program ?

We could do the same in Xojo by saving a folder with stuff in it in the temp directory and then when the user saves, we could zip it in temp and move it to their desired location… On open, it could be unzipped to temp, and then loaded.

That’s pretty cool although it might be easier to just use an encrypted sqlite db.

Does Xojo care if we change the sqlite extension to something else when accessing the file?

I’ll have to look at my code : I believe that what I do in my WebFileUploader is to check the file extension and reject the upload if it’s “.zip”. Perhaps I can code a workaround and see if it’s really .zip which is a .pages file or what. I’m not sure, however, if the data is exposed to me or if by the time it happens it’s too late.

I’m pretty sure the user was not uploading a 500MB+ file, but I do think it’s probably due to the .pages file being either a flat file vs. a package, and also seems to be browser dependent as well.

As an aside, Greg was so nice to help me with large file downloads in Web Apps. I’ll be releasing that in a few days. I got it working quite nicely on the flight back home last night!

One of the benefits of coming to XDC ( hint, hint)

Update: it seems that it’s fairly easy to handle this. In WebFileUploader.FileAdded, you can detect if you see “.pages.zip” as the filename and just strip off the “.zip” part. Then, in WebFileUploader.FileComplete, again strip off the .zip extension and save the file just as .pages.