kitchen-site icon indicating copy to clipboard operation
kitchen-site copied to clipboard

Storage adapter customization

Open kjetilge opened this issue 9 years ago • 2 comments

I can't fin a way add stores to an FS.Collection. It would be nice to have an extra field in "collection" where one could specify a file with an array of extra stores. (in addition to files)

Like:

//extra_stores.js
[
        new FS.Store.FileSystem("thumbs", {
                transformWrite: function(fileObj, readStream, writeStream) {
                 gm(readStream, fileObj.name()).resize('200', '200').stream().pipe(writeStream);
        },
        new FS.Store.FileSystem("avatar", {
                transformWrite: function(fileObj, readStream, writeStream) {
                 gm(readStream, fileObj.name()).resize('80', '80').stream().pipe(writeStream);
        }
      })
]

I've tried to find a way to fake it, but right now all I can do is to add a second files.js file with the complete Collection definition and remove the generated one from the output folder.

Is there a better way to get transforms right now ?

kjetilge avatar Jan 28 '16 18:01 kjetilge

In situations like this (e.g something required not possible by the meteor kitchen cli / json ) diff and patch has solved the problems. Old goog makefile / grunt / npm / gulp / sh-script with proper invocations works like a treat ;)

Simple, but over complicated build script for one of my projects:

#!/bin/bash

ID=insert_app_id_here
URL=http://www.meteorkitchen.com/api/getapp/json/$ID

function build {
 echo Starting meteor-kitchen build
 meteor-kitchen APP.json OUTPUT
 # here's the patch to support google login with additional scopes
 patch -p0 < login.patch
}

# fetch the json and also make a backup 
function once {
    curl -s  $URL > APP.json.new
    mv APP.json.new APP.json
    cp APP.json backup/APP.json-"`date`"
    # git add APP.json
    # git commit -m "Autobuild running for $ID"
    build 
}

# run the build once ;)
once

example patch generated by "diff -u" against a modified version:

--- OUTPUT/client/views/login/login.1.js    2015-12-18 09:38:24.537570130 +0000
+++ OUTPUT/client/views/login/login.js  2015-12-18 09:39:34.029578186 +0000
@@ -58,7 +58,8 @@

        Meteor.loginWithGoogle(
            {
-               requestPermissions: ["email"]
+               forceApprovalPrompt:false, requestOfflineToken: { google: true },
+               requestPermissions: ["https://www.googleapis.com/auth/gmail.readonly"]
            },
            function(err) {
                button.button("reset");

ljack avatar Feb 01 '16 23:02 ljack

Yeah i'm interested in this as well, mainly to be able to create thumbnails to use as needed:

https://github.com/CollectionFS/Meteor-CollectionFS#image-manipulation

tripflex avatar Nov 28 '17 21:11 tripflex