Skip to content
This repository has been archived by the owner on Mar 14, 2019. It is now read-only.

meteor-collectionFS Can't upload #1034

Open
Imokeq opened this issue Jun 5, 2018 · 1 comment
Open

meteor-collectionFS Can't upload #1034

Imokeq opened this issue Jun 5, 2018 · 1 comment

Comments

@Imokeq
Copy link

Imokeq commented Jun 5, 2018

Hello, everyone!

I encountered a problem when using collectionFS

The browser reported an error while uploading the image

1.  PUT.................... 503 (Service Unavailable)      cfs_upload-http.js
2.Error: "Queue" failed [503] Error in method "/cfs/files/:value/:value/", 
Error: MongoError: Mod on _id not allowed     at Function.MongoError.create (/usr/operater/.meteor/packages/npm-mon... [undefined], 
Error: failed [503] Error in method "/cfs/files/:value/:value/", 
Error: MongoError: Mod on _id not allowed     at Function.MongoError.create (/usr/operater/.meteor/packages/npm-mon... 
[undefined]
    at cfs_upload-http.js?hash=306e43cc9d8394be78a109ac76d47adb40af9e27:382
    at cfs_upload-http.js?hash=306e43cc9d8394be78a109ac76d47adb40af9e27:108
    at underscore.js?hash=884c0f04552531e604be5ca6d94381bbf1550f5c:794
    at XMLHttpRequest.xhr.onreadystatechange (cfs_upload-http.js?hash=306e43cc9d8394be78a109ac76d47adb40af9e27:231)

The following error occurred after clicking the splicing url of the uploaded image in the browser console:

1. Error in method "/cfs/files/:value/:value/:value/", Error: TypeError: Cannot read property 'images-original' of undefined
2. at Object.httpGetHandler (packages/cfs_access-point.js:380:33)
3. at Object.get (packages/cfs_access-point.js:698:39)
4. at packages/cfs_http-methods.js:604:33

I get this when I run the app:

I20180606-10:55:52.828(8)? images-original FileSystem mounted on: /testimages/pic
I20180606-10:55:52.905(8)? FS.HTTP.unmount:
I20180606-10:55:52.906(8)? {}
I20180606-10:55:52.906(8)? Registered HTTP method URLs:
I20180606-10:55:52.907(8)? /cfs/files/:collectionName/:id/:filename
I20180606-10:55:52.907(8)? /cfs/files/:collectionName/:id
I20180606-10:55:52.907(8)? /cfs/files/:collectionName
I20180606-10:55:52.913(8)? Server up
=> Meteor server restarted

FS.debug Print log:


I20180606-10:22:22.803(8)? token: eyJhdXRoVG9rZW4iOiJCUmlFRDFtd1ZXYjh6R1hadnRUNmktTVFVMXlTNjZMUG1ITEVEVi1kVVVjIn0=
I20180606-10:22:22.808(8)? HTTP PUT (update) handler received chunk:  0
I20180606-10:22:22.808(8)? GET FILERECORD: S5ZdbMAp5XGA75xdc
I20180606-10:22:22.810(8)? _tempstore FileSystem mounted on: /usr/operater/testApp/testOne/.meteor/local/cfs/files/_tempstore
I20180606-10:22:22.810(8)? TempStore is mounted on storage.filesystem
I20180606-10:22:23.245(8)? token: eyJhdXRoVG9rZW4iOiJCUmlFRDFtd1ZXYjh6R1hadnRUNmktTVFVMXlTNjZMUG1ITEVEVi1kVVVjIn0=
I20180606-10:22:23.248(8)? HTTP PUT (update) handler received chunk:  0
I20180606-10:22:23.249(8)? GET FILERECORD: S5ZdbMAp5XGA75xdc
I20180606-10:22:23.324(8)? token: eyJhdXRoVG9rZW4iOiJCUmlFRDFtd1ZXYjh6R1hadnRUNmktTVFVMXlTNjZMUG1ITEVEVi1kVVVjIn0=
I20180606-10:22:23.328(8)? HTTP PUT (update) handler received chunk:  0
I20180606-10:22:23.328(8)? GET FILERECORD: S5ZdbMAp5XGA75xdc
I20180606-10:22:23.372(8)? token: eyJhdXRoVG9rZW4iOiJCUmlFRDFtd1ZXYjh6R1hadnRUNmktTVFVMXlTNjZMUG1ITEVEVi1kVVVjIn0=
I20180606-10:22:23.375(8)? HTTP PUT (update) handler received chunk:  0
I20180606-10:22:23.375(8)? GET FILERECORD: S5ZdbMAp5XGA75xdc
I20180606-10:22:23.438(8)? token: eyJhdXRoVG9rZW4iOiJCUmlFRDFtd1ZXYjh6R1hadnRUNmktTVFVMXlTNjZMUG1ITEVEVi1kVVVjIn0=
I20180606-10:22:23.441(8)? HTTP PUT (update) handler received chunk:  0
I20180606-10:22:23.442(8)? GET FILERECORD: S5ZdbMAp5XGA75xdc


It seems the upload is interrupted

## Here's my code

in cilent/main.js:

Template.mytemplate.events({
  'change #uploadfile': function(event, template) {
    idCardImgInsert();
  },
  'click #idcards': function(event) {
    console.log(Session.get('imgId'));
    return alert('##');
  },
})

function idCardImgInsert() {
  var idCardImageUrl = '';
  var idCardImg = new FS.File($('#uploadfile').get(0).files[0]);
  console.log('idCardImg', idCardImg);
  if (idCardImg) {
    var idCardImgObj = Images.insert(idCardImg, function(err, result) {
      if (err) console.log(err);

      console.log(result);
    });
    if (idCardImgObj.original.name) {
      idCardImageUrl = "http://103.231.255.47:8090/cfs/files/" +
        idCardImgObj.collectionName +
        "/" + idCardImgObj._id + "/" + idCardImgObj.original.name;
      idCardImageId = idCardImgObj._id;

      console.log(idCardImgObj);

      console.log(idCardImageUrl);
      idCardImgObj.url({
        brokenIsFine: true
      });
      Session.set("imgId", idCardImgObj._id);
      console.log('imgId', idCardImgObj._id);
    }
  }
  var idCardUrl = {
    idCardImageUrl: idCardImageUrl,
  }
  return idCardUrl;
}

FS.HTTP.setBaseUrl('/cfs');

in lib/images.js:

FS.debug = true;

Images = new FS.Collection('Images', {
  stores: [new FS.Store.FileSystem('images-original', {
    path: '/usr/operater/testApp/uploads/pic'
  })],
  internal: true,
  filter: {
    maxSize: 204800, // in bytes
    allow: {
      contentTypes: ['image/*'],
      extensions: ['png', 'jpg', 'jpeg', 'img'],
    },
    onInvalid: function(message) {
      if (Meteor.isClient) {
        alert(message);
      } else {
        console.log(message);
      }
    }
  }
});

if (Meteor.isServer) {
  Meteor.startup(function() {
    console.log("Server up");
  });
}

in server/server.js:

Images.allow({
  'insert': function(userId, party) {
    return true;
  },
  'update': function(userId, party) {
    return true;
  },
  'remove': function(userId, party) {
    return true;
  },
  'download': function(userId, fileObj) {
    return true;
  },

});

Meteor.publish('Images', function(selector) {
  var userId = this.userId;
  return Images.find(selector);
});

packags:

cfs:filesystem 0.1.2
cfs:standard-packages 0.5.10
cfs:tempstore 0.1.6
cfs:ui 0.1.3
ecmascript 0.10.9
es5-shim 4.7.3
insecure 1.0.7
jquery

meteor version:1.6.1
mongodb version:2.4.9

What's wrong with the configuration?
please help me!!!!

@Imokeq Imokeq mentioned this issue Jun 5, 2018
@Imokeq Imokeq changed the title meteor-collectionFS meteor-collectionFS Can't upload Jun 5, 2018
@ravi1100
Copy link

I can't upload image file from firefox browser. It's working in Chrome.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants