bengott/meteor-avatar

Add upload functionality

Closed this issue · 12 comments

I've had some preliminary success integrating particle4dev:upload-avatar into a test project. For this project, however, I would need to modify it a fair amount in order to achieve what I want. The method of saving the image directly on the user object as a base64-encoded string does work though.
@particle4dev: Would you be interested in collaborating/contributing on this?

@Kestanous had suggested using vsivsi:file-collection, which is another file upload option. It has some other nice features like HTTP interfaces and resumable uploads too. Dunno if those features are explicitly necessary, but they might be nice to have.

Anyone have opinions on this?

I haven´t used it myself yet, but another candidate could be CollectionFS, which seems also popular on atmosphere. It provides also S3 storage, which would be great for large scale deployments.

https://github.com/CollectionFS/Meteor-CollectionFS
http://collectionfs.github.io/Meteor-CollectionFS/

vsivsi (the author of fileCollection) describes the difference between the two as:

"Here's the difference in a nutshell: collectionFS is a Ferrari, and file-collection is a Fiat.

They do approximately the same thing using some of the same technologies, but reflect different design priorities. file-collection is much simpler and somewhat less flexible; but if it meets your needs you'll find it has a lot fewer moving parts and may be significantly more efficient to work with and use."

Here's the comment on my crater.io post where @Kestanous suggested using file-collection. Hehe, I also liked the Ferrari/Fiat analogy. :)

We both tended to think that CollectionFS would be overkill for the Avatar package, but @Kestanous also suggested the possibility of supporting it via hooks (something I'll have to look into).

Yes, the Ferrari definitely feels slightly overkill :) My only concern with "file-collection" is that it stores the files in GridFS (MongoDB). For deployments with many users that could add unnecessary load to the database and impact general Meteor performance. Might be possible to extend file-collection with an S3 storage adapter though, if needed.

I also had the intention of getting these two to work with each other. Could you share your project?
What sort of modifications would be required?

@timothyarmes: I created a repo for my test app (one of them, at least). You can check it out here:
https://github.com/bengott/avatar-tester

The particle4dev:upload-avatar package worked OK and it gave me some ideas, but I would need to change the UI, and I want some of the features provided by file-collection.

I had intended looking at adding this functionality myself, but in hindsight I think it's a bad idea.

I don't think that this project should add file uploading itself. It's much better to allow users to pick and choose from existing solutions so that they can find one that best matches their site's design.

If you were to include such a feature then that would bloat the code base for those of us that choose to use another package alongside to handle the upload (since the upload code in this package would be unused).

As you know, in the pull request that I've made I've added an option to provide a per-user avatar URL which will be user in preference when it's available. This solution would be automatically compatible with any other 3rd-party avatar picker.

Should you wish to offer your own upload/crop feature then I think a better approach would be to create a separate sister project which you should mention in the readme file of this project. Users can then either install both packages or else pick and choose freely.

Awesome package!

One simple enhancement would be have a hook when images are not found and have the app provide the image URL.. Here is a little sketch:

Avatar.registerHook("ImageNotFound", function (userIdentifier) {
.... look it up in vsivsi or collections 2 blobs or whatever
return { imageUrl: imageUrl, ... any other parameters you need }
}

That way the storage of the image is left to the app to figure it out.

I think, you may also look for the image src link in profile.avatar - this way project author may have avatar uploads done manually over CollectionFS or whatever he uses in his project.

I'd prefer this functionality. This is really simple & flexible solution.

@bengott what do you think?

@shkomg I created a pull request ages ago to do that, but it's not been accepted for some reason.

@timothyarmes sad to hear :( I'd love having that feature!

Couldn't we just use cloudinary to store the uploaded images? So we don't need to host them and cloudinary gives you also a lot of features like crop, create thumbnails..

+1