Comments (4)
Wouldn't it make more sense if keystone.Field.Types.File
has the option to support multiple files or there's a FileCollection
type?
from keystone-storage-adapter-s3.
the same way no, but I have used an different model Images and an relationship to that model:
one model:
Image.add({
img : { type: Types.File, storage: s3Storage }
});
MyModel.add({
files : { type: Types.Relationship, ref: 'Image', many: true, note: 'Images from Users.' }
});
save route example:
new MyModel(data).save().then( function(mymodel){
MyModel.findById( mymodel._id ).exec().then(function(mymodel){ //get mymodel unpopulated to avoid error
keystone.list('MyModel').updateItem( mymodel, data, { files: req.files }, function(err){ // update the mymodel with files step 1
if(err) return error(err,'Preview save error.');
var ids = [],
saveImage = function iteratee(item, callback) {
new Image({ img: item }).save().then( function(image){
Img.updateItem( image, { img: item }, { files: req.files }, function(err){
if(err) return error(err,'Client Design Image upload error.');
ids.push(image._id);
callback();
});
});
},
success = function(){ // After Images Saved Successfully
// console.log('Ids: ', ids);
mymodel.images = ids;
mymodel.save().then(function(){
// next operation here if any..
});
};
// console.log('Type: ', typeof(imgs));
switch( typeof(imgs) ){
case 'string': saveImage( imgs, success ); break;
case 'object': async.eachSeries(imgs, saveImage, success); break;
default:
mymodel.populate('ingredient container', function(err,mymodel){
//next operation here if any
});
}
}, function(err){ if(err) return error(err, 'MyModel update error.'); } );
}, function(err){ if(err) return error(err, 'MyModel find error.'); } );
}, function(err){ if(err) return error(err, 'MyModel save error.'); } );
from keystone-storage-adapter-s3.
Has there been any follow up or work arounds for this? I really need to upload multiple images to S3 just like I could with the CloudinaryImages type. Any help would be greatly appreciated!
from keystone-storage-adapter-s3.
That's a decent workaround ^^ 👍
from keystone-storage-adapter-s3.
Related Issues (20)
- No option to use original filename HOT 5
- No support for IAM roles HOT 2
- Cloudfront support HOT 2
- Problem with updates and deletes HOT 6
- failure to prefix path with `/` results in leaking local directory info into s3 url HOT 2
- pre:upload option is gone? HOT 1
- schema option to presave image dimensions HOT 1
- Compatibility with latest Keystone version HOT 3
- Note field option
- S3 Multiple Uploads HOT 1
- ACL: "public-read" HOT 9
- Define endpoint to use other s3 compatible object storage HOT 1
- Public URL is incorrectly generated? HOT 1
- uploads added to /tmp on server HOT 1
- Digital Ocean Spaces support? HOT 1
- `encodeSpecialCharacters()` behaviour
- Dynamic path HOT 1
- Original Filename HOT 4
- "Field errors" HOT 13
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from keystone-storage-adapter-s3.