org.springframework.data.mongodb.gridfs.GridFsTemplate Java Examples

The following examples show how to use org.springframework.data.mongodb.gridfs.GridFsTemplate. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BeihuMongoDataAutoConfiguration.java    From beihu-boot with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean
public GridFsTemplate gridFsTemplate(MongoDbFactory mongoDbFactory,
		MongoTemplate mongoTemplate) {
	return new GridFsTemplate(
			new GridFsMongoDbFactory(mongoDbFactory, this.beihuMongoProperties),
			mongoTemplate.getConverter());
}
 
Example #2
Source File: DefaultMongoStoreImpl.java    From spring-content with Apache License 2.0 5 votes vote down vote up
public DefaultMongoStoreImpl(GridFsTemplate gridFs, PlacementService placer) {
	Assert.notNull(gridFs, "gridFs cannot be null");
	Assert.notNull(placer, "placer cannot be null");

	this.gridFs = gridFs;
	this.placer = placer;
}
 
Example #3
Source File: DataMongoDBApplication.java    From building-microservices with Apache License 2.0 5 votes vote down vote up
@Bean
CommandLineRunner exampleGridFs(GridFsTemplate fs) {
	return (args) -> {
		// Write
		fs.store(new ByteArrayInputStream("a-picture-of-car".getBytes()), "pic1");
		// Read
		InputStream stream = fs.getResource("pic1").getInputStream();
		System.err
				.println(StreamUtils.copyToString(stream, Charset.defaultCharset()));
	};
}
 
Example #4
Source File: GridDaoImpl.java    From beihu-boot with Apache License 2.0 4 votes vote down vote up
public GridDaoImpl(GridFsTemplate gridFsTemplate) {
    this.gridFsTemplate = gridFsTemplate;
}
 
Example #5
Source File: BeihuMongoDataAutoConfiguration.java    From beihu-boot with Apache License 2.0 4 votes vote down vote up
/**
 * 文件操作接口
 */
@Bean
@ConditionalOnMissingBean
public GridDao gridDao(GridFsTemplate gridFsTemplate) {
	return new GridDaoImpl(gridFsTemplate);
}
 
Example #6
Source File: GridFsStoreResource.java    From spring-content with Apache License 2.0 4 votes vote down vote up
public GridFsStoreResource(Resource delegate, GridFsTemplate gridfs) {
	Assert.isInstanceOf(GridFsResource.class,
			"delegate must be an instance of GridFsResource");
	this.delegate = (GridFsResource) delegate;
	this.gridfs = gridfs;
}
 
Example #7
Source File: GridFsStoreResource.java    From spring-content with Apache License 2.0 4 votes vote down vote up
public GridFsStoreResource(String location, GridFsTemplate gridfs) {
	Assert.notNull(location, "location must be specified");
	Assert.notNull(location, "gridfs must be specified");
	this.location = location;
	this.gridfs = gridfs;
}
 
Example #8
Source File: EnableMongoStoresTest.java    From spring-content with Apache License 2.0 4 votes vote down vote up
@Bean
public GridFsTemplate gridFsTemplate() throws Exception {
	return new GridFsTemplate(mongoDbFactory(), mappingMongoConverter());
}
 
Example #9
Source File: MongoDbStorageService.java    From jsflight with Apache License 2.0 4 votes vote down vote up
private GridFsTemplate getGridFsTemplate()
{
    return new GridFsTemplate(mongoDbFactory, mappingMongoConverter);
}
 
Example #10
Source File: MongoConfig.java    From tutorials with MIT License 4 votes vote down vote up
@Bean
public GridFsTemplate gridFsTemplate() throws Exception {
    return new GridFsTemplate(mongoDbFactory(), mappingMongoConverter());
}