Make a .bin file out of it, AKA MacBinary. I recall there even is a module, Mac::Conversions, which can encode and decode the file for you — assuming you're trying process the file before upload through MacPerl. I can only assume that is what you're trying to do. If not, perhaps the module Mac::Macbinary could help, it allegedly works on non-Mac platforms too, though I have no experience with it whatsoever.
A MacBinary file is a flattened file, with data fork and resource fork both stored in a normal, non-Mac compatible binary file, and with the original file name, creator type and file type somewhere in there as well. If you append the ".bin" file extension, a Mac will most likely recognize it automatically.
Another possibility is a .hqx file, AKA "BinHex", but that will make the files 33% larger, and smartass browsers on non-Mac platforms may try to decode it for you, if somebody is trying to use such a browser to download the file.
| [reply] |
Off the top of my head:
If you're getting people to upload to a mac and you're concerned that you're not getting the right file associations for double-clicking, then there's two fixes:
- Firstly make sure people upload files with extensions (like 'PhotoshopFile.psd'). Doing that, your mac will use File Exchange to associate with the correct application.
- Secondly, you could get the file type of the uploaded file. This can be ascertained in several ways, possibly including using the content-type of the upload. Once you get this you can either use MacPerl to change the file's Type and Creator to get your associations right or you could rename the file with an appropriate extension to get File Exchange to fix it.
| [reply] |
Not sure what platform you are on, but if you are on OS X and have access to an OS X Server machine, grab a copy of macbin from /usr/bin/. You can use it to macbinarize and de-macbinarize files, and it is quite handy. Otherwise, as others have mentioned, Mac::Macbinary is a good approach. Supplying a correct file extension will help but you macbinarizing will preserve the resource fork & HFS metadata.
| [reply] |
Perhaps you should elaborate just a bit. Tell us what you hope to acheive as well as what you have tried so far (with code, if you have any). Then we will be to give you the guidance you seek.
Based on the little bit of info above, my answer is for you to look up the binmode() Perl function and to read the docs on CGI.pm.
| [reply] [d/l] |
Maybe you should consider using macbinary:
http://search.cpan.org/author/MIYAGAWA/Mac-Macbinary-0.04/Macbinary.pm
| [reply] |
Thanks for all the help so far! I will look into the macbinary module. Meanwhile a little info on my goals.
We are in the process of setting up a new internal web server to provide ftp services for our clients. To make sure we know of a new file arrival we will be providing an html form for uploading. Some of our clients will be using Macintosh and we need to use the same platform for reliable output. The html form will email us on upload with file information. I am aware that the transfer isn't ftp but it is easier this way for some of our clients. Our new internal server will be using OS X Server. We are accomplishing this now by providing instructions and links to freeware Macintosh file encoders but would like to automate the process.
Thanks again,
Cliff | [reply] |