Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for GridFS (mongodb) #45

Open
aperezl opened this issue Oct 11, 2018 · 6 comments
Open

Support for GridFS (mongodb) #45

aperezl opened this issue Oct 11, 2018 · 6 comments

Comments

@aperezl
Copy link

aperezl commented Oct 11, 2018

Hi,

I have started working on a backend storage for gridfs. At the moment I have done some tests and all have been satisfactory.

My idea is to have a new storage for apostrophecms, although at the moment we also have to make changes in the apostrophe-attachments module. (I wish this was not necessary).

My question is, do you think it might be interesting to have this new backend storage? Is there a possibility that it will be published?

Thanks.

@boutell
Copy link
Member

boutell commented Oct 12, 2018 via email

@aperezl
Copy link
Author

aperezl commented Oct 12, 2018

Hi,

I need to inject gridfSBucket and express from attachments to be used by uploadfs (I do not want to create new dependencies in this module). It may not be necessary at the end and only 2 files would be needed in uploadfs (the backend and the test)

At the moment I only have the basics, but I have been able to create and visualize files in Heroku with mLab.

I agree that mongo is not an optimal solution for a large CMS, but for a small blog or academic use it may be fine.

Thanks for the opportunity

@boutell
Copy link
Member

boutell commented Oct 16, 2018

Right... Mongo is a great database solution for a CMS of any size, but for uploaded media file storage it probably makes sense only for smaller sites.

As for injecting the mongodb driver, I see your point. You could make a separate connection in uploadfs, but to save resources it makes sense to accept an existing db object, and that raises the question of how apostrophe-attachments knows to provide it to you. We'd accept a PR to include db in the uploadfs options if storage is set to gridfs; that would be a simple and practical fix.

You also need Express, yes, so you can set up a way for the files to actually be served. Once again, it would be fine for apostrophe-attachments to push self.apos.app to uploadfs if storage is set to gridfs.

@aperezl
Copy link
Author

aperezl commented Oct 16, 2018

That is exactly my approach :) (A little example)

    if(self.uploadfsSettings.backend === 'gridfs') {
      var GridFSBucket =  require('mongodb').GridFSBucket
      var bucket = new GridFSBucket(self.apos.db, { bucketName: 'tracks' })
      _.merge(self.uploadfsSettings, {
        bucket: bucket,
        app: self.apos.app
      });
    }

@boutell
Copy link
Member

boutell commented Oct 16, 2018 via email

@boutell
Copy link
Member

boutell commented Oct 16, 2018 via email

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

No branches or pull requests

2 participants