Meteor-Files with AWS

#1

I’m trying to follow these steps:


but the onAfterUpload function is not called. I only see the files locally on my computer.
I see them here:
C:\rony\my-server.meteor\local\build\programs\server\assets\app\uploads\attachments
and this is part of my code:

const UserFiles = new FilesCollection({
		debug: true, // Change to `true` for debugging
		storagePath: 'assets/app/uploads/attachments',
		collectionName: 'userFiles',
		// Disallow Client to execute remove, use the Meteor.method
		allowClientCode: false,

		// Start moving files to AWS:S3
		// after fully received by the Meteor server
	onAfterUpload(fileRef) {
#2

Maybe onBeforeUpload returns false, preventing the call to onAfterUpload?

#3

‘onBeforeUpload’ is also not called : (
and I don’t see the definition of ‘onAfterUpload’ in ‘FilesCollection’. Should it be there?

#4

The Collection is not exported by the module:

const UserFiles = ....

// should be

export const UserFiles = ....
#5

I’m adding “import S3 from ‘aws-sdk/clients/s3’;”
and the app crashes on:
var zeroBuffer = new Buffer(intSize); zeroBuffer.fill(0);
Buffer is not defined

#6

sounds like you are trying to execute server side code on the client. add a if (Meteor.isServer) {...} around the new Buffer code.

#7

It’s my code. It’s in the file ‘moduls.js’.

#8

Now onBeforeUpload is called, and I return true;
onAfterUpload is still not called.
I have this on the console:
“[FilesCollection] [UploadInstance] [sendEOF] false”
from core.js