Hello,
I'm currently trying to implement your great work into my app, but I'm getting stuck and I'm pretty sure it's an easy fix, since I have tried numerous packages for file upload, and I had succeeded in making yours work, but now I can't seem to remember what I did to fix this in the first time (I had the exact same issue).
So here is my problem :
Each time I try uploading an image, I get this error in the alert :
'MeteorFileWrite7e458a7a8b08855665e6d1f9545…6020a5e65dfdd026cfcaaea01890d181' not found [404]
and this one is the console :
'MeteorFileAbort7e458a7a8b08855665e6d1f95453b9fa6020a5e65dfdd026cfcaaea01890d181' not found [404]
I know it means that it can't find a method, and I must have written something on the worng side of the app, but I can't find what exactly.
Here is my image.js file (on shared side) :
export const Images = new FilesCollection({
storagePath: 'assets/app/uploads/Images',
downloadRoute: '/uploads',
collectionName: 'Images',
allowClientCode: true, // Disallow remove files from Client
public: true,
debug: true,
onBeforeUpload: function (file) {
// Allow upload files under 10MB, and only in png/jpg/jpeg formats
if (file.size <= 10485760 && /png|jpg|jpeg/i.test(file.extension)) {
return true;
} else {
return 'Please upload image, with size equal or less than 10MB';
}
}
});
//Images.collection.attachSchema(new SimpleSchema(Images.schema));
if (Meteor.isServer) {
Meteor.publish('images', function imagesPublication() {
return Images.find({
$or: [
{ private: { $ne: true } },
{ owner: this.userId },
],
});
});
Images.allow({
insert: function() {
return true;
},
update: function() {
return true;
},
remove: function() {
return true;
}
});
}
if (Meteor.isClient) {
Meteor.subscribe('images');
}
I have a template newCloth.html with a form in which I hope to be able to uplaod a n image :
<template name="newCloth">
{{# autoForm collection=Clothes id="newClothForm" type="insert"}}
<fieldset>
(form code...)
{{#if currentUpload}}
{{#with currentUpload}}
<div class="file-field input-field">
Uploading <b>{{file.name}}</b> :
<span id="progress">{{progress}} %</span>
</div>
{{/with}}
{{else}}
<div class="file-field input-field">
<div class="btn">
<span id="progress">Upload</span>
<input id="fileInput" type="file" /><br/>
</div>
</div>
<br/><br/><br/>
{{/if}}
<button type="submit" class="btn btn-primary">{{ getSubmit }}</button>
<button type="reset" class="btn btn-default">{{ getReset }}</button>
</fieldset>
{{/autoForm}}
</template>
and here are my helpers and events for the template (newCloth.js) :
import { Clothes } from '../../api/cloth.js';
import { Images } from '../../api/image.js';
import './newCloth.html';
Template.newCloth.onRendered(function() {
//code needed so the select displays with materialize
});
Template.newCloth.onCreated(function () {
this.currentUpload = new ReactiveVar(false);
});
Template.newCloth.helpers({
Clothes: function(){
return Clothes;
},
currentUpload: function () {
return Template.instance().currentUpload.get();
},
(...)
});
Template.newCloth.events({
'change #fileInput': function (e, template) {
if (e.currentTarget.files && e.currentTarget.files[0]) {
// We upload only one file, in case
// multiple files were selected
var upload = Images.insert({
file: e.currentTarget.files[0],
streams: 'dynamic',
chunkSize: 'dynamic'
}, false);
upload.on('start', function () {
template.currentUpload.set(this);
});
upload.on('uploaded', function (error, fileObj) {
if (!error) {
sweetAlert('File "' + fileObj.name + '" successfully uploaded');
}
});
upload.on('error', function (error, fileObj) {
sweetAlert("Error !", 'Error during upload', "error");
console.log(error);
});
upload.start();
}
}
});
var newClothHooks = {
(hooks for submitting...)
}
AutoForm.addHooks('newClothForm', newClothHooks);
I'm sorry that's a lot of code, but I'm desperate, I've been working on image upload for a week now and everything seems to fail at some point...
Thank you for your work, and for your time and help in advance.
Hi @TheYojimbo ,
debug flag?1.6.0 from dev branch, lots of fixes thereThank you for using this package, I appreciated.
Thanks @dr-dimitru for your very quick response !
So :
[FilesCollection] [insert()]
ostrio_files.js?hash=ab30950…:2199[FilesCollection] [insert] [Tracker] [continue]
ostrio_files.js?hash=ab30950…:2226[FilesCollection] [insert] using WebWorkers
ostrio_files.js?hash=ab30950…:2010loadFile yojimbo.jpg: 22.917ms
ostrio_files.js?hash=ab30950…:1962insert yojimbo.jpg: 37.417ms
ostrio_files.js?hash=ab30950…:1969[FilesCollection] [insert] [end] Error: errorClass
newCloth.js:64errorClassdetails: undefinederror: 404errorType: "Meteor.Error"message: "Method 'MeteorFileWrite7e458a7a8b08855665e6d1f95453b9fa6020a5e65dfdd026cfcaaea01890d181' not found [404]"reason: "Method 'MeteorFileWrite7e458a7a8b08855665e6d1f95453b9fa6020a5e65dfdd026cfcaaea01890d181' not found"stack: (...)get stack: stack()set stack: stack()__proto__: Error
debug.js:41Error invoking Method 'MeteorFileAbort7e458a7a8b08855665e6d1f95453b9fa6020a5e65dfdd026cfcaaea01890d181': Method 'MeteorFileAbort7e458a7a8b08855665e6d1f95453b9fa6020a5e65dfdd026cfcaaea01890d181' not found [404]
I might try tommorow the dev version, if you don't know from where this come from... But I know there is a fix, because it worked fine once this week ! I shouldn't have uninstalled it, but I did not know how to upload my files.
Thanks again, it's an amazing work !
{transport: 'http'} to options in .insert() method?var upload = Images.insert({
file: e.currentTarget.files[0],
streams: 'dynamic',
chunkSize: 'dynamic',
transport: 'http'
}, false);
I don't get any errors, but nor do I get the confirmation alert... Here are the browser logs :
[FilesCollection] [insert()]
ostrio_files.js?hash=ab30950…:2199[FilesCollection] [insert] [Tracker] [continue]
ostrio_files.js?hash=ab30950…:2226[FilesCollection] [insert] using WebWorkers
ostrio_files.js?hash=ab30950…:2010loadFile rick-and-morty.jpg: 26.650ms
addCloth:1 Uncaught SyntaxError: Unexpected token < in JSON at position 0
I don't get the last one, seems like a syntax issue but I don't see where...
console.log(FilesCollection), right before export const Images = new FilesCollection({/*...*/});BTW update to [email protected], there is several connectivity issues is fixed
Ok I started the update, it's taking a long time. I'll keep you updated on the log as soon as I have the app running again.
Oh and yes, the cookies were disabled, so I just added an exception for localhost:3000.
Ok so the update didn't change anything, and the log gives me (still in the client console) :
function FilesCollection(config) { //
var _methods, cookie, localStorageSupport, self;
and if I click on it I get into ostrio_files.js.
I'm sure I made a mistake somewhere, forgot something, but I can't figure out what... that's frustrating.
ostrio:files higher in .meteor/packages? (_doesn't seems to be related, but try_)I'll try tommorow, it's getting late here.
Again, thank you very much for your help !
Ok I moved ostrio:files to the top in .meteor/packages, didn't change anything.
Now, I'm gonna go ahead and ask a stupid question, but how do I update to the dev version ?
In meteor's project dir (_btw it's better to Google it_):
mkdir packages
cd packages
git clone https://github.com/VeliovGroup/Meteor-Files.git
git checkout dev
cd ../
meteor update && meteor
Hi @TheYojimbo ,
Any news on your end?
Hi @dr-dimitru, Sorry I'm using meteor for a school project, and this week I was at work. I'll try tommorow and will keep you updated.
@TheYojimbo please, keep this thread updated. Thank you.
Hello again,
So I've tried updating to dev version, but something went wrong during the update :
=> Errors while upgrading packages:
While building package ostrio:files:
error: couldn't install npm packages from npm-shrinkwrap: Command failed: npm ERR! git clone
C:\Users\Yojimbo\AppData\Roaming\npm-cache\_git-remotes\git-https-github-com-rynomad-jsbn-git-bb522b0124f75424f89d49446c
40a87111942c7b-e72d386d
C:\Users\Yojimbo\AppData\Local\Temp\npm-168-318e20c1\git-cache-cfcd04f8\bb522b0124f75424f89d49446c40a87111942c7b:
Cloning into
'C:\Users\Yojimbo\AppData\Local\Temp\npm-168-318e20c1\git-cache-cfcd04f8\bb522b0124f75424f89d49446c40a87111942c7b'...
npm ERR! git clone
C:\Users\Yojimbo\AppData\Roaming\npm-cache\_git-remotes\git-https-github-com-rynomad-jsbn-git-bb522b0124f75424f89d49446c
40a87111942c7b-e72d386d
C:\Users\Yojimbo\AppData\Local\Temp\npm-168-318e20c1\git-cache-cfcd04f8\bb522b0124f75424f89d49446c40a87111942c7b:
error: cannot spawn sh: No such file or directory
npm ERR! git clone
C:\Users\Yojimbo\AppData\Roaming\npm-cache\_git-remotes\git-https-github-com-rynomad-jsbn-git-bb522b0124f75424f89d49446c
40a87111942c7b-e72d386d
C:\Users\Yojimbo\AppData\Local\Temp\npm-168-318e20c1\git-cache-cfcd04f8\bb522b0124f75424f89d49446c40a87111942c7b:
fatal: unable to fork
npm ERR! git clone
C:\Users\Yojimbo\AppData\Roaming\npm-cache\_git-remotes\git-https-github-com-rynomad-jsbn-git-bb522b0124f75424f89d49446c
40a87111942c7b-e72d386d
C:\Users\Yojimbo\AppData\Local\Temp\npm-168-318e20c1\git-cache-cfcd04f8\bb522b0124f75424f89d49446c40a87111942c7b:
npm ERR! Windows_NT 10.0.10586
npm ERR! argv
"C:\\Users\\Yojimbo\\AppData\\Local\\.meteor\\packages\\meteor-tool\\1.3.4_1\\mt-os.windows.x86_32\\dev_bundle\\bin\\\\n
ode.exe"
"C:\\Users\\Yojimbo\\AppData\\Local\\.meteor\\packages\\meteor-tool\\1.3.4_1\\mt-os.windows.x86_32\\dev_bundle\\lib\\nod
e_modules\\npm\\bin\\npm-cli.js"
"install"
npm ERR! node v0.10.45
npm ERR! npm v3.9.6
npm ERR! code 128
npm ERR! Command failed: Cloning into
'C:\Users\Yojimbo\AppData\Local\Temp\npm-168-318e20c1\git-cache-cfcd04f8\bb522b0124f75424f89d49446c40a87111942c7b'...
npm ERR! error: cannot spawn sh: No such file or directory
npm ERR! fatal: unable to fork
npm ERR!
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
npm ERR! git clone
C:\Users\Yojimbo\AppData\Roaming\npm-cache\_git-remotes\git-https-github-com-rynomad-jsbn-git-bb522b0124f75424f89d49446c
40a87111942c7b-e72d386d
C:\Users\Yojimbo\AppData\Local\Temp\npm-168-318e20c1\git-cache-cfcd04f8\bb522b0124f75424f89d49446c40a87111942c7b:
Cloning into
'C:\Users\Yojimbo\AppData\Local\Temp\npm-168-318e20c1\git-cache-cfcd04f8\bb522b0124f75424f89d49446c40a87111942c7b'...
npm ERR! git clone
C:\Users\Yojimbo\AppData\Roaming\npm-cache\_git-remotes\git-https-github-com-rynomad-jsbn-git-bb522b0124f75424f89d49446c
40a87111942c7b-e72d386d
C:\Users\Yojimbo\AppData\Local\Temp\npm-168-318e20c1\git-cache-cfcd04f8\bb522b0124f75424f89d49446c40a87111942c7b:
error: cannot spawn sh: No such file or directory
npm ERR! git clone
C:\Users\Yojimbo\AppData\Roaming\npm-cache\_git-remotes\git-https-github-com-rynomad-jsbn-git-bb522b0124f75424f89d49446c
40a87111942c7b-e72d386d
C:\Users\Yojimbo\AppData\Local\Temp\npm-168-318e20c1\git-cache-cfcd04f8\bb522b0124f75424f89d49446c40a87111942c7b:
fatal: unable to fork
npm ERR! git clone
C:\Users\Yojimbo\AppData\Roaming\npm-cache\_git-remotes\git-https-github-com-rynomad-jsbn-git-bb522b0124f75424f89d49446c
40a87111942c7b-e72d386d
C:\Users\Yojimbo\AppData\Local\Temp\npm-168-318e20c1\git-cache-cfcd04f8\bb522b0124f75424f89d49446c40a87111942c7b:
npm ERR! Windows_NT 10.0.10586
npm ERR! argv
"C:\\Users\\Yojimbo\\AppData\\Local\\.meteor\\packages\\meteor-tool\\1.3.4_1\\mt-os.windows.x86_32\\dev_bundle\\bin\\\\n
ode.exe"
"C:\\Users\\Yojimbo\\AppData\\Local\\.meteor\\packages\\meteor-tool\\1.3.4_1\\mt-os.windows.x86_32\\dev_bundle\\lib\\nod
e_modules\\npm\\bin\\npm-cli.js"
"install"
npm ERR! node v0.10.45
npm ERR! npm v3.9.6
npm ERR! code 128
npm ERR! Command failed: Cloning into
'C:\Users\Yojimbo\AppData\Local\Temp\npm-168-318e20c1\git-cache-cfcd04f8\bb522b0124f75424f89d49446c40a87111942c7b'...
npm ERR! error: cannot spawn sh: No such file or directory
npm ERR! fatal: unable to fork
npm ERR!
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
And now I can't even launch my project, I get these errors every time...
I'll try updating node, I'll keep you updated, but if you have any idea where this might come from, I'm listening !
Yes, which version of Meteor you're on? Check .meteor/release
Try to meteor reset && meteor update
PS F:\Mes Documents\Textes\sms-base> meteor reset
Project reset.
PS F:\Mes Documents\Textes\sms-base> meteor update
This project is already at Meteor 1.3.4.1, the latest release.
ostrio:files: updating npm dependencies -- fs-extra, request, throttle, file-type...
=> Errors while upgrading packages:
While building package ostrio:files:
error: couldn't install npm packages from npm-shrinkwrap: Command failed: npm ERR! git fetch -a origin
(https://github.com/rynomad/jsbn.git) fatal: Unable to find remote helper for 'https'
npm ERR! Windows_NT 10.0.10586
npm ERR! argv
"C:\\Users\\Yojimbo\\AppData\\Local\\.meteor\\packages\\meteor-tool\\1.3.4_1\\mt-os.windows.x86_32\\dev_bundle\\bin\\\\n
ode.exe"
"C:\\Users\\Yojimbo\\AppData\\Local\\.meteor\\packages\\meteor-tool\\1.3.4_1\\mt-os.windows.x86_32\\dev_bundle\\lib\\nod
e_modules\\npm\\bin\\npm-cli.js"
"install"
npm ERR! node v0.10.45
npm ERR! npm v3.9.6
npm ERR! code 128
npm ERR! Command failed: fatal: Unable to find remote helper for 'https'
npm ERR!
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
npm ERR! git fetch -a origin (https://github.com/rynomad/jsbn.git) fatal: Unable to find remote helper for 'https'
npm ERR! Windows_NT 10.0.10586
npm ERR! argv
"C:\\Users\\Yojimbo\\AppData\\Local\\.meteor\\packages\\meteor-tool\\1.3.4_1\\mt-os.windows.x86_32\\dev_bundle\\bin\\\\n
ode.exe"
"C:\\Users\\Yojimbo\\AppData\\Local\\.meteor\\packages\\meteor-tool\\1.3.4_1\\mt-os.windows.x86_32\\dev_bundle\\lib\\nod
e_modules\\npm\\bin\\npm-cli.js"
"install"
npm ERR! node v0.10.45
npm ERR! npm v3.9.6
npm ERR! code 128
npm ERR! Command failed: fatal: Unable to find remote helper for 'https'
npm ERR!
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
npm rebuild && npm update && npm rebuild, for more info see this SO-answer (_use NVM if you install packages directly via NPM without_ meteor npm....): http://stackoverflow.com/questions/30130692/dyld-lazy-symbol-binding-failed-symbol-not-found-node-module-register/33125622#33125622
Tried that, did nothing :
PS F:\Mes Documents\Textes\sms-base> npm rebuild
PS F:\Mes Documents\Textes\sms-base> npm update
PS F:\Mes Documents\Textes\sms-base> npm rebuild
PS F:\Mes Documents\Textes\sms-base> node -v
v6.2.2
PS F:\Mes Documents\Textes\sms-base> meteor update
This project is already at Meteor 1.3.4.1, the latest release.
ostrio:files: updating npm dependencies -- fs-extra, request, throttle, file-type...
=> Errors while upgrading packages:
While building package ostrio:files:
error: couldn't install npm packages from npm-shrinkwrap: Command failed: npm ERR! git fetch -a origin
(https://github.com/rynomad/jsbn.git) fatal: Unable to find remote helper for 'https'
npm ERR! Windows_NT 10.0.10586
npm ERR! argv
"C:\\Users\\Yojimbo\\AppData\\Local\\.meteor\\packages\\meteor-tool\\1.3.4_1\\mt-os.windows.x86_32\\dev_bundle\\bin\\\\n
ode.exe"
"C:\\Users\\Yojimbo\\AppData\\Local\\.meteor\\packages\\meteor-tool\\1.3.4_1\\mt-os.windows.x86_32\\dev_bundle\\lib\\nod
e_modules\\npm\\bin\\npm-cli.js"
"install"
npm ERR! node v0.10.45
npm ERR! npm v3.9.6
npm ERR! code 128
npm ERR! Command failed: fatal: Unable to find remote helper for 'https'
npm ERR!
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
npm ERR! git fetch -a origin (https://github.com/rynomad/jsbn.git) fatal: Unable to find remote helper for 'https'
npm ERR! Windows_NT 10.0.10586
npm ERR! argv
"C:\\Users\\Yojimbo\\AppData\\Local\\.meteor\\packages\\meteor-tool\\1.3.4_1\\mt-os.windows.x86_32\\dev_bundle\\bin\\\\n
ode.exe"
"C:\\Users\\Yojimbo\\AppData\\Local\\.meteor\\packages\\meteor-tool\\1.3.4_1\\mt-os.windows.x86_32\\dev_bundle\\lib\\nod
e_modules\\npm\\bin\\npm-cli.js"
"install"
npm ERR! node v0.10.45
npm ERR! npm v3.9.6
npm ERR! code 128
npm ERR! Command failed: fatal: Unable to find remote helper for 'https'
npm ERR!
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
I hadn't installed node on this computer before, so maybe I just forgot to install some package or dependency ?
Install and use NVM as described in this post
Meteor needs v0.10.45, you have v6.2.2
Ok sorry I'm a little bit slow to understand sometime.
Here is where I'm at :
PS F:\Mes Documents\Textes\sms-base> nvm use 0.10.45
Now using node v0.10.45 (64-bit)
PS F:\Mes Documents\Textes\sms-base> npm rebuild
PS F:\Mes Documents\Textes\sms-base> npm update
PS F:\Mes Documents\Textes\sms-base> npm rebuild
PS F:\Mes Documents\Textes\sms-base> node -v
v0.10.45
PS F:\Mes Documents\Textes\sms-base> meteor update
This project is already at Meteor 1.3.4.1, the latest release.
ostrio:files: updating npm dependencies -- fs-extra, request, throttle, file-type...
=> Errors while upgrading packages:
While building package ostrio:files:
error: couldn't install npm packages from npm-shrinkwrap: Command failed: npm ERR! git submodule -q update --init
--recursive: fatal: 'submodule' appears to be a git command, but we were not
npm ERR! git submodule -q update --init --recursive: able to execute it. Maybe git-submodule is broken?
npm ERR! git submodule -q update --init --recursive:
npm ERR! Windows_NT 10.0.10586
npm ERR! argv
"C:\\Users\\Yojimbo\\AppData\\Local\\.meteor\\packages\\meteor-tool\\1.3.4_1\\mt-os.windows.x86_32\\dev_bundle\\bin\\\\node.exe"
"C:\\Users\\Yojimbo\\AppData\\Local\\.meteor\\packages\\meteor-tool\\1.3.4_1\\mt-os.windows.x86_32\\dev_bundle\\lib\\node_modules\\npm\\bin\\npm-cli.js"
"install"
npm ERR! node v0.10.45
npm ERR! npm v3.9.6
npm ERR! code 128
npm ERR! Command failed: fatal: 'submodule' appears to be a git command, but we were not
npm ERR! able to execute it. Maybe git-submodule is broken?
npm ERR!
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
npm ERR! git submodule -q update --init --recursive: fatal: 'submodule' appears to be a git command, but we were
not
npm ERR! git submodule -q update --init --recursive: able to execute it. Maybe git-submodule is broken?
npm ERR! git submodule -q update --init --recursive:
npm ERR! Windows_NT 10.0.10586
npm ERR! argv
"C:\\Users\\Yojimbo\\AppData\\Local\\.meteor\\packages\\meteor-tool\\1.3.4_1\\mt-os.windows.x86_32\\dev_bundle\\bin\\\\n
ode.exe"
"C:\\Users\\Yojimbo\\AppData\\Local\\.meteor\\packages\\meteor-tool\\1.3.4_1\\mt-os.windows.x86_32\\dev_bundle\\lib\\nod
e_modules\\npm\\bin\\npm-cli.js"
"install"
npm ERR! node v0.10.45
npm ERR! npm v3.9.6
npm ERR! code 128
npm ERR! Command failed: fatal: 'submodule' appears to be a git command, but we were not
npm ERR! able to execute it. Maybe git-submodule is broken?
npm ERR!
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
Looks like it's not the same problem...
Could you try to run the same command on Linux or Mac?
I don't have any installed, I could set up a Ubuntu on virtualbox, but it would take long to set up.
If there is no other solution I'll try it tommorow if you want.
It's definitely Windows related.
I recommend you to remove everything (including node, npm and meteor)
Download and build from sources [email protected], then install meteor again
@TheYojimbo any news on your end?
I just uninstalled everything, reinstalled Node 0.10.45, then Meteor, same thing. I then deleted the package folder containing the dev version, updated meteor, it completed.
So I tried to run meteor, it started smoothly, and when I tried uploading an image I had a different error this time :
Failed to load resource: the server responded with a status of 404 (Not Found)
ostrio_files.js:2427 [FilesCollection] [insert()]
ostrio_files.js:2817 [FilesCollection] [insert] [Tracker] [continue]
ostrio_files.js:2918 [FilesCollection] [insert] [.continue()]
ostrio_files.js:2845 [FilesCollection] [insert] using WebWorkers
ostrio_files.js:2773 [FilesCollection] [.call(_Start)] Error: errorClass(anonymous function) @ ostrio_files.js:2773
ostrio_files.js:2554 insert abandoned image.jpg: 23.938ms
ostrio_files.js:2561 [FilesCollection] [insert] [end] Error: errorClassFilesCollection._UploadInstance.Meteor.isClient.UploadInstance.end @ ostrio_files.js:2561
ostrio_files.js:2941 [FilesCollection] [insert] [.abort()]
ostrio_files.js:2907 [FilesCollection] [insert] [.pause()]
app.js:1424 errorClassdetails: undefinederror: 404errorType: "Meteor.Error"message: "Method '_FilesCollectionStart_Images' not found [404]"reason: "Method '_FilesCollectionStart_Images' not found"stack: (...)get stack: stack()set stack: stack()__proto__: Error
meteor.js:930 Error invoking Method '_FilesCollectionAbort_Images': Method '_FilesCollectionAbort_Images' not found [404]
Have you updated to v1.6.2 ?
Yes, when I updated Meteor, it updated Meteor-Files to 1.6.2
console.log(FilesCollection._methodNames); // <- Replace FilesCollection with its instance of Images collection
.abort() method is called?Might be related to #128
Hey @dr-dimitru sorry for answering so late, I've been busy at work, but now I have all week to fix this.
So for your questions, console.log(FilesCollection._methodNames); gives me undefined on client console, I don't have any idea why abort is called, and still no clients logs...
Okay, that's weird...
What do you get for console.log(FilesCollection);?
Just to make sure, have you changed FC to its instance name?
// <- Replace FilesCollection with its instance of Images collection
Sorry I didn't read the commentary :S
Here is the result of console.log(Images._methodNames); :
Object
_Abort : "_FilesCollectionAbort_Images"
_Remove : "_FilesCollectionRemove_Images"
_Start : "_FilesCollectionStart_Images"
_Write : "_FilesCollectionWrite_Images"
console.log(FilesCollection); still give me the same thing as before.
Try this in browser console:
Meteor.call('_FilesCollectionStart_Images', function(){
console.log(arguments);
});
Meteor.call('_FilesCollectionStart_Images', function(){
console.log(arguments);
});
undefined
[errorClass, undefined]
0: errorClass
details: undefined
error: 404
errorType: "Meteor.Error"
message: "Method '_FilesCollectionStart_Images' not found [404]"
reason: "Method '_FilesCollectionStart_Images' not found"
stack: (...)
get stack: stack()
set stack: stack()
__proto__: Error
1: undefinedcallee: ()
length: 2
Symbol(Symbol.iterator): values()
__proto__: Object
No, idea...
new keyword?.js files instead .jsx (_not sure if this will help, but you should try_)@TheYojimbo Any news on your end?
Hey @dr-dimitru good news, my team mate found the problem : it was exactly as I thought at first, I just forgot something. I hadn't imported the collection on the server, which explain the lack of server logs and the Meteor Method not found.
So I just added « import { Images } from '../imports/api/images/image.js'; » on server/main.js, and now everything works fine.
I'm really sorry for the inconvenience, and want to thank you for your patience and your time, you did an amazing work, thank you.
Now I just have to make it work with the rest of the project.
Sorry again, and thanks.
@TheYojimbo you're welcome thank you for update from your end.
EDIT: forget about this comment, it's the same error, I didn't run the code on the server side.
I got a similar error, but I checked my import which is correct.
I am using the latest meteor(1.4) and ostrio:files from meteor add.
server code:
import { FilesCollection } from 'meteor/ostrio:files';
export const Files = new FilesCollection({
collectionName: 'files',
allowClientCode: false, // Disallow remove files from Client
debug: true,
onBeforeUpload: function (file) {
// Allow upload files under 100MB
if (file.size <= 100485760){
return true;
} else {
return 'Please upload file with size equal or less than 100MB';
}
}
});
if (Meteor.isServer) {
Meteor.publish('files', function () {
return Files.find().cursor;
});
}
client code:
import { Files } from '../../api/files.js';
...
Meteor.subscribe('files');
$ctrl.upload = function(){
console.log(Files);
var upload = Files.insert({
file: document.getElementById('file').files[0],
streams: 'dynamic',
chunkSize: 'dynamic'
}, false);
upload.on('start', function () {
//template.currentUpload.set(this);
});
upload.on('end', function (error, fileObj) {
if (error) {
alert('Error during upload: ' + error);
} else {
alert('File "' + fileObj.name + '" successfully uploaded');
}
//template.currentUpload.set(false);
});
upload.start();
}
Here is the error:

Just for information, this bug isn't Windows related. I've encountered it on Linux and I think it can be found on Mac too :)
@mafzst
@dr-dimitru
I solved it by importing my FileCollection server side (as said in previous comments).
I'm using 1.5.6
Definitively not. It's not only related with server side importing. It sounds a bit mysterious for me.
Here a working code:
import { FilesCollection } from 'meteor/ostrio:files';
export const Files = new FilesCollection({
collectionName: 'files',
allowClientCode: false,
onBeforeUpload: (file) => {
if (file.size <= 10485760 && /png|jpg|jpeg/i.test(file.extension)) {
return true;
} else {
return 'Not ok';
}
}
});
The collection is called by (truncated)
import { Files } from '/imports/api/files/files'; #File containing the code above
onDrop: (files) => {
console.debug(files[0]);
let upload = Files.insert({
file: files[ 0 ]
}, false)
.on('start', () => {
console.group("Uploading...");
console.info("Upload started");
})
.on('progress', (progress, file) => {
console.info(`Uploading ${file.name} (${progress})`);
})
.on('end', (error, file) => {
if (error) {
console.error(error);
console.debug(error.getStack());
} else {
console.info(`File ${file.name} uploaded`);
console.debug(file);
dispatch(addFile(file));
}
console.groupEnd();
})
.start();
}
Now I want to implement dynamic storagePath by wrapping FilesCollection declaration. Here my code:
export const FilesCollectionFactory = (client) => {
return new FilesCollection({
collectionName: `files`,
allowClientCode: false,
storagePath: `../../../../../../static/${client}/media`,
onBeforeUpload: (file) => {
if (file.size <= 10485760 && /png|jpg|jpeg/i.test(file.extension)) {
return true;
} else {
return 'Not ok';
}
}
})
}
And called with the same code as the succesfull attemp but by creating variable to handle generated FileCollection (const Files = FilesCollectionFactory('blahblahblah');
The encountered error is :
{
error: 404,
reason: "Method 'MeteorFileWriteed17d58b5d798b333f85b167562a983d368a68a95aea078760f0c9aecc653af4' not found",
details: undefined,
message: "Method 'MeteorFileWriteed17d58b5d798b333f85b167562…368a68a95aea078760f0c9aecc653af4' not found [404]",
errorType: "Meteor.Error"
}
Collection name inside FilesCollectionFactory function must be different, then it will work
I've tried by adding client name it it, but that fix nothing :(
Are you running this code on both client and server?
You've right!It's finally the same problem :)
The collection is created by a Factory, so it isn't the same instance on client and on server
Call method from Factory to call same code on server
I've found another solution to achieve my goal.
I've just posted because I think I've found another way to reproduce the bug but finally it's the same problem :)
Thank for your time :+1:
Glad you've solved it
Please, support this project by:
Most helpful comment
Hey @dr-dimitru good news, my team mate found the problem : it was exactly as I thought at first, I just forgot something. I hadn't imported the collection on the server, which explain the lack of server logs and the Meteor Method not found.
So I just added « import { Images } from '../imports/api/images/image.js'; » on server/main.js, and now everything works fine.
I'm really sorry for the inconvenience, and want to thank you for your patience and your time, you did an amazing work, thank you.
Now I just have to make it work with the rest of the project.
Sorry again, and thanks.