HI everybody,
Thanks for this awesome package,
i setup the package to work with S3 upload, everything seems to work fine...
my problem is to display the images on the client,
i have a helper who bring me the url with the .link() function.
but when i try to access http://localhost:3000/cdn/storage/2uvdTA7XXnNNtizss.png
i've got an error from flow router :
kadira_flow-router.js?hash=4ca3941…:519 There is no route for the path: /cdn/storage/2uvdTA7XXnNNtizss.png
how can i setup flow router to drive the request correctly ? what i'am doing wrong ?
i presume the magic is located under the interceptDownload function ?
Thanks for your help.
Best regards,
Léo
Hello @lleoooell ,
Could you please post your .meteor/packages file?
My quick guess is kadira:flow-router placed above ostrio:files, if I'm right - that means flow-router intercepts requests and not passing it no next listener. To solve this, simply place ostrio:files above kadira:flow-router in .meteor/packages file
Hi @dr-dimitru
Thanks for your quick answer !
Your guess was right, but it solved 50% of the problem, with ostrio:files above kadira:flow-router, there is no more error message of 'no route for path' in the client console...but still a 404 page not found...
(this fix on the packages file make me thinking about how my deployment with mup - i'm new with this tool - will be done, if i change my packages lines order on my local laptop, will this change be reflected on my server or a new package file will be created ? - maybe this is a noob question because mup only copy paste my local package file to my remote instance ? sorry for this...)
thanks a lot,


{debug: true} passed into FilesCollection constructor - so we will see if request reaches FilesCollection, and where it stuck. Post here both Client and Server logs

my guess is that i really have a problem with my intercept function...
FileCursor#link() method or {{fuleURL fileObj}} helper?onAfterUpload() as link generated out of the record in MongoDB, and your screenshot (with requested URL) indicates what something is missingwhen i upload a picture with my S3 setup i presume everything is ok for the upload part :

but as soon as i try to display it :

and here is the function, basically the one pasted from the example :
interceptDownload(http, fileRef, version) {
let path;
if (fileRef && fileRef.versions && fileRef.versions[version] && fileRef.versions[version].meta && fileRef.versions[version].meta.pipePath) {
path = fileRef.versions[version].meta.pipePath;
}
if (path) {
// If file is successfully moved to AWS:S3
// We will pipe request to AWS:S3
// So, original link will stay always secure
// To force ?play and ?download parameters
// and to keep original file name, content-type,
// content-disposition, chunked "streaming" and cache-control
// we're using low-level .serve() method
const opts = {
Bucket: s3Conf.bucket,
Key: path
};
if (http.request.headers.range) {
const vRef = fileRef.versions[version];
let range = _.clone(http.request.headers.range);
const array = range.split(/bytes=([0-9]*)-([0-9]*)/);
const start = parseInt(array[1]);
let end = parseInt(array[2]);
if (isNaN(end)) {
// Request data from AWS:S3 by small chunks
end = (start + this.chunkSize) - 1;
if (end >= vRef.size) {
end = vRef.size - 1;
}
}
opts.Range = `bytes=${start}-${end}`;
http.request.headers.range = `bytes=${start}-${end}`;
}
const fileColl = this;
s3.getObject(opts, function (error) {
if (error) {
console.error(error);
if (!http.response.finished) {
http.response.end();
}
} else {
if (http.request.headers.range && this.httpResponse.headers['content-range']) {
// Set proper range header in according to what is returned from AWS:S3
http.request.headers.range = this.httpResponse.headers['content-range'].split('/')[0].replace('bytes ', 'bytes=');
}
const dataStream = new stream.PassThrough();
fileColl.serve(http, fileRef, fileRef.versions[version], version, dataStream);
dataStream.end(this.data.Body);
}
});
return true;
}
// While file is not yet uploaded to AWS:S3
// It will be served file from FS
return false;
}
Could you add console.log(fileColl) after it's defined and before .serve to check what is there?
I'm generating a link like that :
_in my template html :
<img class="pulseImg" src="{{getImageById imgId}}">
getImageById is a global client helper :
Template.registerHelper('getImageById', function(id) {
var test = Images.findOne({"_id" : id});
console.log(test.link());
return test.link();
});
here is my console log fileCol

Could you check what is inside test ? console.log(test)
according to your log fileCol is exists and has right value.
What FilesCollection version you're on? May be it's too old to have .serve?
test looks like this :

ostrio file version is :
ostrio:[email protected]
(many thanks for your help)
Yes ostrio:[email protected] is too old to have .serve, and may have other bugs.
Could you update?
Funny thing today ostrio:[email protected] is exactly an year old
yes, i did !!!! and it woks right now...
I'm sorry for all of this...and thank you so much for your time...i only install package with meteor add...and didn't check the version...
i run
meteor update ostrio:file
(it update to 1.7.)
then i had to install fs extra :
meteor npm install fs.extra --save
and file type,
meteor npm install file-type --save
because i had this error :
Error: Can't find npm module 'file-type'. Did you forget to call 'Npm.depends' in package.js within the 'ostrio_files' package?
same for fs extra.
but now, everything is working...thank you so much !!!!!!!
but now, everything is working...thank you so much !!!!!!!
Great! 👍
then i had to install fs extra :
and file type,
Yes, latest release have annoying issue with NPM dependencies, stay tuned for updates at #420
I'm sorry for all of this...and thank you so much for your time...i only install package with meteor add...and didn't check the version...
No worries, I'm glad to help. Check out our other meteor packages.
Please, support this project by:
done ^^
@fmorgens If you've solved your issue — feel free to share a solution
Most helpful comment
yes, i did !!!! and it woks right now...
I'm sorry for all of this...and thank you so much for your time...i only install package with meteor add...and didn't check the version...
i run
meteor update ostrio:file
(it update to 1.7.)
then i had to install fs extra :
meteor npm install fs.extra --save
and file type,
meteor npm install file-type --save
because i had this error :
Error: Can't find npm module 'file-type'. Did you forget to call 'Npm.depends' in package.js within the 'ostrio_files' package?
same for fs extra.
but now, everything is working...thank you so much !!!!!!!