Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Macintosh upload

by Stimpy (Novice)
on Nov 25, 2002 at 20:14 UTC ( [id://215720]=perlquestion: print w/replies, xml ) Need Help??

Stimpy has asked for the wisdom of the Perl Monks concerning the following question:

I would like to find a way to preserve Macintosh files during upload. Not just stripping out the resource fork, but actually preserving the data, so that the files are recognized by a Macintosh. If decoding with Stuffit is needed after upload, this would be fine.
Thanks,
Cliff

Replies are listed 'Best First'.
Re: Macintosh upload
by bart (Canon) on Nov 25, 2002 at 21:53 UTC
    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.

Re: Macintosh upload
by BigLug (Chaplain) on Nov 26, 2002 at 00:07 UTC
    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.
Re: Macintosh upload
by moof1138 (Curate) on Nov 26, 2002 at 03:40 UTC
    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.
Re: Macintosh upload
by Mr. Muskrat (Canon) on Nov 25, 2002 at 21:12 UTC

    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.

      Maybe you should consider using macbinary: http://search.cpan.org/author/MIYAGAWA/Mac-Macbinary-0.04/Macbinary.pm
Re: Macintosh upload
by Anonymous Monk on Dec 02, 2002 at 12:32 UTC
    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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://215720]
Approved by newrisedesigns
Front-paged by newrisedesigns
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2024-04-18 03:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found