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

Using File Collection S3 storage adapter, where to put bucket #50

Open
anthonymanzo opened this issue Jan 24, 2017 · 13 comments
Open

Using File Collection S3 storage adapter, where to put bucket #50

anthonymanzo opened this issue Jan 24, 2017 · 13 comments

Comments

@anthonymanzo
Copy link

Hi,
I have this code in the kitchen json:
"collections" : [ { "name":"employee_pictures", "type":"file_collection", "storage_adapters":["s3"] },
And I've set my S3 access keys in my settings.json inside of the env property. However, I have no place to put the s3 bucket name and hence meteor throws an error when I compile:

W20170124-10:26:11.768(-8)? (STDERR) Error: FS.Store.S3 you must specify the "bucket" option
W20170124-10:26:11.768(-8)? (STDERR) at new FS.Store.S3 (packages/cfs_s3.js:114:11)

Where should I put this info?
Also, I haven't been able to find examples of how to use a fs collection in the examples, yet the s3 and fs storage adapters are mentioned in the API. Is this just a stub, or is it supported?

Thanks again.
Tony

@perak
Copy link
Owner

perak commented Jan 24, 2017

@anthonymanzo

Hi Tony,

To be honest I never used S3 storage adapter with file collection, but let's modify kitchen to allow this. Can you please let me know what/where to add/change to make S3 works properly? Maybe you can provide minimal .json file and modify generated code to allow S3 works - that would be perfect.

@perak
Copy link
Owner

perak commented Jan 24, 2017

(example-upload, generated code modified manually to allow S3 storage is perfect - maybe I can modify and deploy fixed kitchen today/tomorrow)

@anthonymanzo
Copy link
Author

anthonymanzo commented Jan 24, 2017 via email

@perak
Copy link
Owner

perak commented Jan 24, 2017

@anthonymanzo OK, in next version 0.9.78 I added this:

Storage adapters now can be defined in storage_adapter_options instead storage_adapters (both works for backward compatibility) like this:

{
	"name": "files",
	"type": "file_collection",
	"storage_adapter_options": { 
		"s3": {
			"bucket": "mybucket",
                        ...
		}
	}
}

And resulting code is:

this.Files = new FS.Collection("files", {
	stores: [
		new FS.Store.S3("files", {
			bucket: "mybucket",
                	...
		})
	]
});

storage_adapter_options is json object with "s3", "dropbox", "filesystem" or "gridfs" in the root, and these objects can contain anything. JSON is converted to javascript and inserted into code.

I hope this helps.

Unfortunately, I'll not able to deploy latest version tonight, I hope I'll deploy tomorrow ~24 hours after now.

@anthonymanzo
Copy link
Author

anthonymanzo commented Jan 24, 2017 via email

@perak
Copy link
Owner

perak commented Jan 25, 2017

@anthonymanzo version 0.9.78 is deployed few minutes ago.

@perak
Copy link
Owner

perak commented Jan 25, 2017

BTW, storage_adapter_options can only be edited directly in json ("source" tab in a GUI) - I didn't implemented "fancy" editor - not yet.

@anthonymanzo
Copy link
Author

Storage adapter code is now showing up in the subscriptions - thanks.
Minor problem, I can't render the images with the data-view component - I need a way to return tags -- would use {{{ employeePictureToImgTag employee_picture }}} but the generated code for th data view is only using the standard handlebars double {{ }} which escapes html.

I am a noob at handlebars/blaze so please forgive my ignorance if this is not an issue.

@perak
Copy link
Owner

perak commented Jan 27, 2017

@anthonymanzo triple braces: already reported here perak/kitchen-site#363 will be fixed in next release.

@anthonymanzo
Copy link
Author

Hi,
Just wanted to give an update that I haven't been able to test this as I'm having trouble with the latest version of cfs:s3 not working for me, I had the old version on lockdown.
I'm going to close this issue for you until then!

@anthonymanzo
Copy link
Author

Hi, another comment on this. Got it working (more or less) and want to know how to define multiple stores for a collection (ie a largthumb, smallthumb set). Any ideas?

@anthonymanzo anthonymanzo reopened this Mar 6, 2017
@anthonymanzo
Copy link
Author

anthonymanzo commented Mar 6, 2017

Here's my code. Kitchen generator is only picking up the first store:
"collections" : [

		{
			"name": "employee_thumbs",
			"type": "file_collection",
			"storage_adapter_options": { 
				"s3": {
					"bucket": "salk-saw-assets",
					"folder":"thumbs",
					"transformWrite":"function(fileObj, readStream, writeStream) {

// Transform the image into a 30x thumbnail
gm(readStream, fileObj.name()).resize('77', '77').stream().pipe(writeStream);
}",
},
"s3": {
"bucket": "salk-saw-assets",
"folder":"large_thumbs",
"transformWrite":"function(fileObj, readStream, writeStream) {
// Make the image a predictable 225px thumbnail
gm(readStream, fileObj.name()).resize('225', '225').stream().pipe(writeStream);
}",
}
}

		},

@perak
Copy link
Owner

perak commented Mar 6, 2017

@anthonymanzo yes, bug is: kitchen enumerates "distinct" storage adapters, instead each one. Will fix that for next release, but I'll not be able to deploy it next ~7 days. I suggest you to use copy_files and write code manually.

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