This project is read-only.

Handling zips created on Mac OSX

Dec 4, 2011 at 12:50 PM


Ran into a bit of a problem with uploading a zip of images created on the mac. 

After a bit of debugging I have discovered that is down to the meta files that OSX creates within a zip.

I have fixed this by editing the ImageGalleryService.UnzipMediaFileArchive method to add a check for the meta files.

protected void UnzipMediaFileArchive(string imageGallery, Stream zipStream)
            Argument.ThrowIfNullOrEmpty(imageGallery, "imageGallery");
            Argument.ThrowIfNull(zipStream, "zipStream");

            using (ZipInputStream fileInflater = new ZipInputStream(zipStream))
                ZipEntry entry;

                while ((entry = fileInflater.GetNextEntry()) != null) {
                    if (!entry.IsDirectory && !string.IsNullOrEmpty(entry.Name)) {
                        // Handle mac osx meta files
                        if (entry.Name.StartsWith("__MACOSX",StringComparison.OrdinalIgnoreCase)) continue;
                        // skip disallowed files
                        if (IsFileAllowed(entry.Name, false)) {
                            string fileName = Path.GetFileName(entry.Name);

                            try {
                                AddImage(imageGallery, fileName, fileInflater);
                            } catch (ArgumentException argumentException) {
                                //if (argumentException.ParamName == entry.Name) {
                                if (argumentException.Message.Contains(fileName)) {
                                    _services.Notifier.Warning(new LocalizedString(string.Format("File \"{0}\" skipped since it already exists.", fileName)));
                                } else {

Maybe this could be added into the next release?



Dec 5, 2011 at 10:15 AM

Hi Jeff,

I'm planning to release a maintenance version this week. I'll add your contribution on it since you already coded it ;-)

Thank you very for your feedback!


Dec 5, 2011 at 7:59 PM

Done! It has been released in version 1.3.