Meteor-Community-Packages / Meteor-CollectionFS

Reactive file manager for Meteor
MIT License
1.05k stars 237 forks source link

Is there no support for Adobe inDesign files? #1022

Open kjrhody opened 6 years ago

kjrhody commented 6 years ago

Is there support for inDesign (.indd, .idml) files with this? From what I can see, the type property for files with that extension continues to be empty despite my best efforts, and errors out on the insert (Error is: Uncaught Error: FS.Collection insert: file does not pass collection filters). My code is this:

HighResFiles = new FS.Collection("highResFiles", {
    stores: [highResStore, highResThumbStore],
    filter: {
        maxSize: 524288000, //500 MB in bytes
        allow: {
            contentTypes: [
                'image/*', 'application/pdf', 'application/octet-stream', 'application/postscript', 'application/msword',
                'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.ms-excel',
                'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/illustrator',
                'application/vnd.ms-powerpoint', 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
                'application/x-indesign'
            ],
            extensions: ['png', 'gif', 'jpg', 'jpeg', 'tif', 'tiff', 'bmp', 'eps', 'svg', 'ps', 'pdf', 'psd', 'doc', 'docx', 'xls', 'xlsx', 'ai', 'ppt', 'pptx', 'indd', 'idml']
        }
    }
});

and

function highResFileUpload(event, template, currentGraphic){
    FS.Utility.eachFile(event, function(file) {
        checkCFSFileType(file, HighResFiles);

       // Here I've tried to account for at least an .indd file but it still errors out
 var fileExtension = _.last(file.name.split('.'));
        if (file.type === "" && fileExtension === "indd"){
            var fileType = "application/x-indesign";
            console.log(fileType);
        } else {
            var fileType = file.type;
            console.log(fileType);

        }

        let newFile = new FS.File();

        newFile.attachData(file, {type: fileType}, function (error) {
            if (error) {
                sAlert.error('Error uploading file: ' + error);
                throw new Meteor.Error("CFS file upload failed");
            }
            newFile.name(file.name);
            newFile.metadata = {
                owner: Meteor.userId(),
                modifiedDate: new Date(Date.parse(file.lastModifiedDate)),
                project_identifier: currentGraphic.project_identifier
            };

            let highResFile = HighResFiles.insert(newFile);

            Graphics.update({_id: currentGraphic._id}, {$push: {highResFiles: highResFile._id}}, function(error){
                if (error) {
                    sAlert.error('Error updating graphic: ' + error);
                    throw new Meteor.Error("Error updating graphic");
                }
                //sAlert.success(currentGraphic.identifier + ' successfully updated');
            });
        });
    });
}
nooitaf commented 6 years ago

Can you give us an example InDesign file which is not working for you?

kjrhody commented 6 years ago

@nooitaf It looks like github doesn't support upload of that file type (.indd) so I had to compress it into a .zip

indesign_figure_Test_v1.indd.zip

kjrhody commented 6 years ago

@nooitaf Any update? Were you able to get the file to work?

nooitaf commented 6 years ago

Sry and thanks for needed ping :)

I downloaden and extracted the zip you uploaded.

The first thing i noticed was that it's a directory, similar to .application/.app "files" on the mac.

$ tree indesign_figure_Test_v1.indd -a

indesign_figure_Test_v1.indd
├── indesign_figure_Test_v1.indd
└── __MACOSX
    └── ._indesign_figure_Test_v1.indd

The directory contains a binary file.

When i check the binary file for it's mime-type with file i get

$ file --mime-encoding --mime-type indesign_figure_Test_v1.indd 

indesign_figure_Test_v1.indd: application/octet-stream; charset=binary

I did a local and production upload check and if you upload the binary file inside, it just works.

You can normaly see the contents of those folders with right click > show-package-contents

I hope this helps