Meteor-Community-Packages / Meteor-CollectionFS

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

Collection FS problems with summernote #695

Open robwatkin opened 9 years ago

robwatkin commented 9 years ago

Hi, I'm trying to understand a problem I'm experiencing inserting a file into the summernote text editor when using a CollectionFS store. Summernote provides an image insert callback which overrides the default behaviour. In this callback I insert the image into my CollectionFS store and in that async callback following comments at [https://github.com/CollectionFS/Meteor-CollectionFS/issues/351]() I have the following code

 fileObj.on("uploaded", function() {
    console.log('editPage onImageUpload CmsImages.insert fileObj.on uploaded...');
    imageURL = '/cfs/files/cms-images/' + fileObj._id;
    $dom = $("<img>").attr('src',imageURL);
    $summernote.summernote("insertNode", $dom[0]);
    ...

and then passing imageURL to summernote's insert method which then throws

GET http://localhost:3000/cfs/files/cms-images/mZsMWhrF5oZwQFbdG 503 (Service Unavailable) I think the problem may be with CollectionFS any advice would be appreciated.

I am also getting a warning in the logs

GET FILERECORD: 8zQmsEBHJkdxQTube upload-http-client.js:22
PUT to URL /cfs/files/cms-images/8zQmsEBHJkdxQTube Object {filename: "tattoo.png", token: "eyJhdXRoVG9rZW4iOiJvN2pzeXg4dVRlMTRDbHRFWEtBekFGWkNkaExmWnpNbG1NYVd3MHI5UGxDIn0="}
http-call-client.js:101 The provided value 'undefined' is not a valid enum value of interface XMLHttpRequestResponseType.

I have tried the "stored" event but that's not firing on my client at all.

Thanks

robwatkin commented 9 years ago

The following hack works on my dev machine

     fileObj.on("uploaded", function() {
        imagesURL = '/cfs/files/cms-images/' + fileObj._id;
        Meteor.setTimeout(function(){
          $dom = $("<img>").attr('src',imagesURL);
          $summernote.summernote("insertNode", $dom[0]);
        }, 100);
      });