精华内容
下载资源
问答
  • MongoDB 存储图片

    万次阅读 2016-08-20 14:03:05
    MongoDB图片存储以及显示

    不同于MongoDB 2.0提供的“GridFS”方式,MongoDB 3.0的图片保存和读取困扰了我一段时间。MongoDB本身是可以存储二进制的,这意味着其存储图片是完全可以的。虽说图片可以保存到本地,数据库只记录相对路径,但是某些时候还是有那么一丝不方便。

    最近修改的一个门户网站,因为要更换数据库,所以难免涉及到数据转换,这个数据转换为我提供了MongoDB 3.0保存图片的思路。之前门户网站使用的是SQLite数据库保存头像等小图片,存储类型是Blob,但是MongoDB是没有Blob这个类型的的。所以只能选择Binary来存储。通过一个小的c#程序,将SQLite数据库的数据转MongoDB中,其中图片存储转换的代码为: user_Image = (byte[])re["User_Head"](user_Image是BsonBinaryData类型)。

    转换完成后,打开MongoBooster查看了一下,发现user_Image是以Base64编码存储从SQLite转过来的Blob类型的数据。这样我们在用MongoDB 3.0存储图片的时候就可以选择Base64编码来存储。只需要在上传图片时将图片转为Base64编码即可。 要将MongoDB的存放的Base64编码的图片在网页上显示,也需要经过一系列转换,因为MongoDB并没有提供getBinary方法,我通过一个比较绕的方法(我想大神们应该有更好的办法,希望得到提示,谢谢)。首先将代码获取到的整个document转为json,MongoDB提供了toJson()方法,然后取出user_Image这个field的值转为String,同时通过"分为多个数组,其中数组的第4部分就是MongoDB中图片以Base64编码存储的值。具体代码为:

    String js = doc.toJson();

    JSONObject jso = JSONObject.fromObject(js);

    String[] strs = jso.get("Icon_Image").toString().split("\"");

    至于在网页上的显示,则直接通过img标签,因为img标签有识别base64的方法

    <img src='data:image/jpg;base64,"+strs[3]+" '/>

    如上MongoDB的图片存储于显示就实现了。方法比较蠢笨,希望得到熟悉MongoDB的朋友能指导一下,给出更好的方法。

    展开全文
  • mongodb存储图片和文件实践

    万次阅读 2017-07-02 16:43:58
    可能很多人会问为何要用mongodb存储图片和文件,我的理由是mongodb作存储方便稳定易扩展,我们自己写的文件存储服务器肯定很LOW,除了含有巨量图片的大型系统,一般由公司自研图片存储外,大部分情况下,我们用...

     

     

    可能很多人会问为何要用mongodb存储图片和文件,我的理由是mongodb作存储方便稳定易扩展,我们自己写的文件存储服务器肯定很LOW,除了含有巨量图片的大型系统,一般由公司自研图片存储外,大部分情况下,我们用mongodb足以应付。另外,很多人根本就不知道或者没尝试过用mongodb存储文件,而对方还故意问我为什么用这个。本文特此奉上代码并提供MongoDBClient与spring的集成。

     

    whatsmars-common
      |-src
        |-main
          |-java
            |-com.itlong.whatsmars.common.mongo
              |-object
                MongoDBConfig.java
                MongoDBCredential.java
                MongoDBDriver.java
                ObjectIdCreator.java
              |-serializer
                CustomDateDeserializer.java
                CustomDateSerializer.java
              GridFSClient.java
              MongoDBClient.java
              ImageSizeEnum.java
      pom.xml
    
    whatsmars-fs-web
      |-src
        |-main
          |-java
            |-com.itlong.whatsmars.fs.web
              |-controller
                FileController.java
              |-service
                |-impl
                  FileServiceImpl.java
                FileService.java
          |-resource
            log4j.xml
            mongodb-config.properties
            spring-context.xml
            spring-mvc-servlet.xml
            spring-service
      pom.xml

     主要依赖:

    <!-- 图片压缩工具 -->
            <dependency>
                <groupId>org.imgscalr</groupId>
                <artifactId>imgscalr-lib</artifactId>
                <version>4.2</version>
            </dependency>
    
            <dependency>
                <groupId>org.mongodb</groupId>
                <artifactId>mongo-java-driver</artifactId>
                <version>3.0.0</version>
            </dependency>

     

    public class MongoDBConfig {
    
        private String addresses;
    
    
        private List<MongoDBCredential> credentials;
    
        public String getAddresses() {
            return addresses;
        }
    
        public void setAddresses(String addresses) {
            this.addresses = addresses;
        }
    
        public List<MongoDBCredential> getCredentials() {
            return credentials;
        }
    
        public void setCredentials(List<MongoDBCredential> credentials) {
            this.credentials = credentials;
        }
    
        public List<MongoCredential> buildCredentials() {
            List<MongoCredential> mongoCredentials = new ArrayList<MongoCredential>();
            for(MongoDBCredential item : this.credentials) {
                MongoCredential credential = MongoCredential.createCredential(item.getUsername(),item.getDatabaseName(),item.getPassword().toCharArray());
                mongoCredentials.add(credential);
            }
            return mongoCredentials;
        }
    
        public List<ServerAddress> buildAddresses() throws Exception{
            List<ServerAddress> serverAddresses = new ArrayList<ServerAddress>();
            String[] sources = addresses.split(";");
            for(String item : sources) {
                String[] hp = item.split(":");
                serverAddresses.add(new ServerAddress(hp[0],Integer.valueOf(hp[1])));
            }
            return serverAddresses;
        }
    }

     

     

     

    public class MongoDBCredential {
    
        private String databaseName;
    
        private String username;
        private String password;
    
        public String getDatabaseName() {
            return databaseName;
        }
    
        public void setDatabaseName(String databaseName) {
            this.databaseName = databaseName;
        }
    
        public String getUsername() {
            return username;
        }
    
        public void setUsername(String username) {
            this.username = username;
        }
    
        public String getPassword() {
            return password;
        }
    
        public void setPassword(String password) {
            this.password = password;
        }
    }

     

     

     

    public class MongoDBDriver {
    
        private Properties properties;
        /**
         */
    private MongoClient mongo = null;
    
        /**
         */
    private Integer connectionsPerHost = 32;
    
        private Integer threadsAllowedToBlockForConnectionMultiplier = 5;
    
        private Integer maxWaitTime = 30000;
        private Integer connectTimeout = 30000;
        private Integer socketTimeout = 30000;
    
        private Integer maxConnectionIdle = 6000;
    
    
        private MongoDBConfig configuration;
    
        public void setProperties(Properties properties) {
            this.properties = properties;
        }
    
        public void setConfiguration(MongoDBConfig configuration) {
            this.configuration = configuration;
        }
    
        public void init() throws Exception{
            if(properties != null){
    
                String perHost = properties.getProperty("mongodb.driver.connectionsPerHost");
                
    if(StringUtils.isNotBlank(perHost)){
                    connectionsPerHost = Integer.valueOf(perHost);
                }
                
    String multiplier = properties.getProperty("mongodb.driver.threadsAllowedToBlockForConnectionMultiplier");
                if(StringUtils.isNotBlank(multiplier)){
                    threadsAllowedToBlockForConnectionMultiplier = Integer.valueOf(multiplier);
                }
                /
    String waitTime = properties.getProperty("mongodb.driver.maxWaitTime");
                if(StringUtils.isNotBlank(waitTime)){
                    maxWaitTime = Integer.valueOf(waitTime);
                }
                
    String ctimeout = properties.getProperty("mongodb.driver.connectTimeout");
                if(StringUtils.isNotBlank(ctimeout)){
                    connectTimeout = Integer.valueOf(ctimeout);
                }
                
    String stimeout = properties.getProperty("mongodb.driver.socketTimeout");
                if(StringUtils.isNotBlank(stimeout)){
                    socketTimeout = Integer.valueOf(stimeout);
                }
                
    String mci = properties.getProperty("mongodb.driver.maxConnectionIdle");
                if(StringUtils.isNotBlank(mci)){
                    maxConnectionIdle = Integer.valueOf(mci);
                }
            }
            init,db check and connected.
    execute();
    
        }
    
        private void execute() throws Exception{
            MongoClientOptions.Builder builder = MongoClientOptions.builder();
            builder.connectionsPerHost(this.connectionsPerHost);
            builder.threadsAllowedToBlockForConnectionMultiplier(threadsAllowedToBlockForConnectionMultiplier);
            builder.socketKeepAlive(true);
            builder.maxWaitTime(this.maxWaitTime);
            builder.connectTimeout(this.connectTimeout);
            builder.socketTimeout(this.socketTimeout);
            builder.maxConnectionIdleTime(maxConnectionIdle);
    
            MongoClientOptions options = builder.build();
    
            this.mongo = new MongoClient(configuration.buildAddresses(), configuration.buildCredentials(),options);
    
        }
    
    
        public void close() {
            mongo.close();
        }
    
        public Mongo getMongo() {
            return mongo;
        }
    
        public MongoDatabase getDatabase(String dbName) {
            return mongo.getDatabase(dbName);
        }
    
        /**
         * old api
         * @param dbName
    * @return
    */
    public DB getDB(String dbName) {
            return mongo.getDB(dbName);
        }
    
    }

     

     

    public class ObjectIdCreator{
    
    	public static String creator(){
    		return new ObjectId().toString();
    	}
    }

      

    public class CustomDateDeserializer extends JsonDeserializer<Date> {
    
    	private static final String[] pattern = { "yyyy-MM-dd HH:mm:ss" };
    
    	@Override
    	public Date deserialize(JsonParser arg0, DeserializationContext arg1)
    			throws IOException, JsonProcessingException {
    		if (JsonToken.VALUE_STRING.equals(arg0.getCurrentToken())) {
    			try {
    				return DateUtils.parseDate(arg0.getText(), pattern);
    			} catch (ParseException e) {
    				e.printStackTrace();
    			}
    		}
    		return null;
    	}
    }

     

    public class CustomDateSerializer extends JsonSerializer<Date> {  
      private static final String pattern = "yyyy-MM-dd HH:mm:ss";
    
      @Override  
      public void serialize(Date value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException {  
        jgen.writeString(DateFormatUtils.format(value, pattern));
      }  
    }

     

    public class MongoDBClient {
    
        protected MongoDBDriver mongoDBDriver;
    
        protected String databaseName;
    
        public void setMongoDBDriver(MongoDBDriver mongoDBDriver) {
            this.mongoDBDriver = mongoDBDriver;
        }
    
    
    
        public void setDatabaseName(String databaseName) {
            this.databaseName = databaseName;
        }
    
        public MongoCollection<Document> getCollection(String collectionName) {
            MongoDatabase db = mongoDBDriver.getDatabase(this.databaseName);
            return db.getCollection(collectionName);
        }
    
        public MongoDatabase getDatabase() {
            return mongoDBDriver.getDatabase(this.databaseName);
        }
    
    
        public static void main(String[] args) throws Exception{
    
            MongoDBDriver mongoDBDriver = new MongoDBDriver();
            try{
                MongoDBConfig mongoDBConfig = new MongoDBConfig();
                //mongoDBConfig.setAddresses("61.171.123.234:27017");
                mongoDBConfig.setAddresses("61.171.123.234:27017");
                List<MongoDBCredential> credentials = new ArrayList<MongoDBCredential>();
                MongoDBCredential credential = new MongoDBCredential();
                credential.setDatabaseName("whatsmars-common");
                credential.setUsername("whatsmars");
                //credential.setPassword("haodai.com");
                credential.setPassword("passwordiscommon");
                credentials.add(credential);
                mongoDBConfig.setCredentials(credentials);
                mongoDBDriver.setConfiguration(mongoDBConfig);
                mongoDBDriver.init();
                MongoDBClient client = new MongoDBClient();
                client.setDatabaseName("whatsmars-common");
                client.setMongoDBDriver(mongoDBDriver);
                ListCollectionsIterable<Document> documents = client.getDatabase().listCollections();
                MongoCursor<Document> it = documents.iterator();
                while (it.hasNext()) {
                    Document item = it.next();
                    System.out.println(item.toJson());
                }
                it.close();
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                mongoDBDriver.close();
            }
        }
    }

     

    public class GridFSClient extends MongoDBClient{
    
        private GridFS _gridFS = null;
    
        private Object lock = new Object();
    
        protected static final String[] IMAGE_FORMAT = {"jpg","jpeg","png"};
    
    
        public void setMongoDBDriver(MongoDBDriver mongoDBDriver) {
            this.mongoDBDriver = mongoDBDriver;
        }
    
        public GridFS getInstance() {
            if(_gridFS != null) {
                return _gridFS;
            }
            synchronized (lock) {
                if(_gridFS != null) {
                    return _gridFS;
                }
                _gridFS = new GridFS(mongoDBDriver.getDB(this.databaseName));
                return _gridFS;
            }
    
        }
    
        public void close() {
            mongoDBDriver.close();
        }
    
        /**
         *
         * @param inputStream 文件流
         * @param format 文件格式,“pdf”,“png”等,不包含后缀符号“.”
         * @return
         */
        public String saveFile(InputStream inputStream,String format,String uid) {
            try {
                GridFS gridFS = getInstance();
    
                //随机生成文件名称,多次重试
                String filename = this.randomFileName();
                //如果有文件重复,则重新生成filename
                while (true) {
                    GridFSDBFile _current = gridFS.findOne(filename);
                    //如果文件不存在,则保存操作
                    if (_current == null) {
                        break;
                    }
                    filename = this.randomFileName();
                }
    
                GridFSInputFile file = gridFS.createFile(inputStream, filename);
                if(format != null) {
                    file.put("format", format);
                }
                if(uid != null) {
                    file.put("uid",uid);
                }
                file.put("content-type","application/octet-stream");
                file.save();
                return concat(filename,format);
            }catch (Exception e) {
    
                throw new RuntimeException(e);
            } finally {
                try{
                    inputStream.close();
                }catch (Exception ex) {
                    //
                }
            }
        }
    
        private String concat(String filename,String format) {
            if(format == null) {
                return filename;
            }
            if(format.startsWith(".")) {
                return filename + format;
            }
            return filename + "." + format;
        }
    
        private String randomFileName() {
            return RandomStringUtils.random(32, true, true).toLowerCase();
        }
    
        public void delete(String filename) {
            GridFS gridFS = getInstance();
            gridFS.remove(filename);
        }
    
        public InputStream getFile(String filename) {
            GridFS gridFS = getInstance();
            GridFSDBFile _current = gridFS.findOne(filename);
            if(_current == null) {
                return null;
            }
            return _current.getInputStream();
        }
    
        public InputStream getImage(String filename,String path) throws Exception{
            //获取最大边,等比缩放
            if(ImageSizeEnum.valueOfPath(path) == null) {
                return null;
            }
    
            GridFS gridFS = getInstance();
            GridFSDBFile _current = gridFS.findOne(filename);
            if(_current == null) {
                return null;
            }
    
            int size = ImageSizeEnum.valueOfPath(path).size;
    
            int max = (Integer)_current.get("max");//图片的实际尺寸
    
            InputStream result = null;
            //裁剪
            if(size < max) {
                InputStream inputStream = _current.getInputStream();
                BufferedImage image = ImageIO.read(inputStream);
    
                inputStream.close();
                ByteArrayOutputStream bos = new ByteArrayOutputStream();
                BufferedImage thumbnail = Scalr.resize(image, size);//保留最大尺寸
                String format = (String) _current.get("format");
                ImageIO.write(thumbnail, format, bos);
                result = new ByteArrayInputStream(bos.toByteArray());
            } else {
                result = _current.getInputStream();
            }
    
            return result;
        }
    
    
        /**
         *
         * @param inputStream 输入流
         * @return
         * @throws Exception
         */
        public String saveImage(InputStream inputStream,String uid) throws Exception{
    
            BundleEntry bundleEntry = this.drain(inputStream);
            if(bundleEntry == null) {
                throw new RuntimeException("file isn't a image!");
            }
    
            ByteArrayInputStream bis = bundleEntry.inputStream;
    
            String _currentFileName = this.isExistedImage(bundleEntry);
    
            //如果文件md5已存在
            if(_currentFileName != null) {
                return _currentFileName;
            }
    
            String format = bundleEntry.format;
            GridFS gridFS = getInstance();
            String filename = this.randomFileName();
            //检测文件名称
            while(true){
                GridFSDBFile _current = gridFS.findOne(filename);
                //如果文件不存在,则保存操作
                if (_current == null) {
                    break;
                }
                //否则,重新生成文件名称
                filename = randomFileName();
            }
            //图片处理
            bis.reset();
    
            //保存原图
            GridFSInputFile _inputFile = gridFS.createFile(bis, filename);
            if(uid != null) {
                _inputFile.put("uid", uid);
            }
            _inputFile.put("max",bundleEntry.max);
            _inputFile.put("crc",bundleEntry.crc);
            _inputFile.put("format",format);
            _inputFile.put("md5_source",bundleEntry.md5);
            _inputFile.save();
    
            return concat(filename,format);
    
        }
    
        private String isExistedImage(BundleEntry entry) {
            GridFS gridFS = getInstance();
            DBObject query = new BasicDBObject();
            query.put("crc",entry.crc);
            query.put("md5_source",entry.md5);
            GridFSDBFile _current = gridFS.findOne(query);
            //根据MD5值查询,检测是否存在
            if(_current == null) {
                return null;
            }
            String format = (String)_current.get("format");
            if(format.startsWith(".")) {
                return _current.getFilename() + format;
            }
            return _current.getFilename() + "." + format;
        }
    
        /**
         * 因为图片的stream需要reset,所以需要将流全部汲取
         * @param inputStream
         * @return
         * @throws Exception
         */
        protected BundleEntry drain(InputStream inputStream) throws Exception{
            //
            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            //计算源文件的md5、crc,以防止图片的重复上传
            Adler32 crc = new Adler32();
            try{
                while(true) {
                    int _c = inputStream.read();
                    if(_c == -1) {
                        break;
                    }
                    bos.write(_c);
                    crc.update(_c);
                }
    
            }catch (Exception e) {
                throw new RuntimeException(e);
            } finally {
                inputStream.close();
            }
    
            //第一步:图片格式
            List<String> formats = new ArrayList<String>();//
            ImageInputStream imageInputStream = ImageIO.createImageInputStream(new ByteArrayInputStream(bos.toByteArray()));
            imageInputStream.mark();
            try {
                Iterator<ImageReader> it = ImageIO.getImageReaders(imageInputStream);
                while (it.hasNext()) {
                    ImageReader reader = it.next();
                    String format  = reader.getFormatName().toLowerCase();
                    if(ArrayUtils.contains(IMAGE_FORMAT, format)) {
                        formats.add(format);
                    }
                }
            }catch (Exception ex) {
                //
            }
    
            //如果格式不合法,则直接返回
            if(formats.isEmpty()) {
                try {
                    imageInputStream.close();
                } catch (Exception e) {
                    //
                }
                return null;
            }
    
            String md5 = DigestUtils.md5Hex(bos.toByteArray());//求原始图片的MD5,和crc
            System.out.println("md5:" + md5);
            imageInputStream.reset();
    
            BufferedImage image = ImageIO.read(imageInputStream);
    
            //获取最大边,等比缩放
            int max = Math.max(image.getHeight(), image.getWidth());
    
            bos = new ByteArrayOutputStream();
            //如果尺寸超过最大值,则resize
            if(max > ImageSizeEnum.PIXELS_MAX.size) {
                max = ImageSizeEnum.PIXELS_MAX.size;
            }
            String format = formats.get(0);
            BufferedImage thumbnail = Scalr.resize(image, max);//保留最大尺寸
            ImageIO.write(thumbnail, format, bos);
    
            return new BundleEntry(new ByteArrayInputStream(bos.toByteArray()),md5,crc.getValue(),format,max);
        }
    
    
        protected class BundleEntry {
            String md5;
            long crc;
            String format;
            int max;
            ByteArrayInputStream inputStream;
            BundleEntry(ByteArrayInputStream inputStream,String md5,long crc,String format,int max) {
                this.md5 = md5;
                this.crc = crc;
                this.inputStream = inputStream;
                this.format = format;
                this.max = max;
            }
        }
    
    
    
        public static void main(String[] args) throws Exception{
    
            MongoDBDriver mongoDBDriver = new MongoDBDriver();
            try {
                GridFSClient client = new GridFSClient();
                MongoDBConfig mongoDBConfig = new MongoDBConfig();
                //mongoDBConfig.setAddresses("61.172.238.149:27017");
                mongoDBConfig.setAddresses("61.172.240.58:27017");
                List<MongoDBCredential> credentials = new ArrayList<MongoDBCredential>();
                MongoDBCredential credential = new MongoDBCredential();
                credential.setDatabaseName("whatsmars-fs");
                credential.setUsername("whatsmars");
                //credential.setPassword("haodai.com");
                credential.setPassword("passwordisfs");
                credentials.add(credential);
                mongoDBConfig.setCredentials(credentials);
                mongoDBDriver.setConfiguration(mongoDBConfig);
                mongoDBDriver.init();
                client.setDatabaseName("whatsmars-fs");
                client.setMongoDBDriver(mongoDBDriver);
                testUpload(client);
                //testClear(client.getInstance());
                //testGetImage(client.getInstance(),"xhgcguccxumuyl9hzdombgfvzgriv7rf",null);
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                mongoDBDriver.close();
            }
    
        }
    
    
        protected static void testClear(GridFS gridFS) {
            DBCursor cursor = gridFS.getFileList();
            while (cursor.hasNext()) {
                DBObject dbObject = cursor.next();
                String filename = (String)cursor.next().get("filename");
                System.out.println(filename);
                System.out.println(dbObject.toString());
                gridFS.remove(filename);
            }
            cursor.close();
        }
    
    
        protected static void testUpload(GridFSClient client) throws Exception{
            FileInputStream inputStream = new FileInputStream(new File("/data/tmp/222222222.jpg"));
    
            try {
    
                String filename = client.saveImage(inputStream, null);
                System.out.println(filename);
                String source = filename.substring(0,filename.lastIndexOf("."));
                System.out.println(source);
                InputStream result = client.getImage(source, "x4");
                if(result == null) {
                    System.out.println("not found!");
                }
                //vejibw36famkscjyksgke7bugzonnyan
    
                FileOutputStream outputStream = new FileOutputStream("/data/tmp/" + filename);
                while (true) {
                    int i = result.read();
                    if( i == -1) {
                        break;
                    }
                    outputStream.write(i);
                }
                outputStream.flush();
                outputStream.close();
                result.close();
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                inputStream.close();
            }
    
        }
    
        protected static void testGetImage(GridFS gridFS,String filename,String path) {
            DBObject query = new BasicDBObject();
            query.put("md5_source","9e131ae4ed7337d4712650229b827725");
            GridFSDBFile file = gridFS.findOne(query);
            if(file != null) {
                System.out.println(file.getFilename());
            }
        }
    
    }

     

    public enum ImageSizeEnum {
    
        PIXELS_200(200, "x2"),
        PIXELS_400(400, "x4"),
        PIXELS_600(600, "x6"),
        PIXELS_800(800, "x8"),
    
        PIXELS_MAX(1024, "xm");//最大1024
        public int size;
    
        public String path;
    
        ImageSizeEnum(int size, String path) {
            this.size = size;
            this.path = path;
        }
    
        public static ImageSizeEnum valueOfPath(String path) {
            if(path == null) {
                return  null;
            }
            for(ImageSizeEnum e : ImageSizeEnum.values()) {
                if(e.path.equalsIgnoreCase(path)) {
                    return e;
                }
            }
            return null;
        }
    }

    mongodb-config.properties:

    mongodb.driver.connectionsPerHost=32
    mongodb.driver.threadsAllowedToBlockForConnectionMultiplier=5
    mongodb.driver.maxWaitTime=30000
    mongodb.driver.connectTimeout=30000
    mongodb.driver.socketTimeout=30000
    mongodb.driver.maxConnectionIdle=60000

      spring-context.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://www.springframework.org/schema/beans
               http://www.springframework.org/schema/beans/spring-beans-3.2.xsd"
            default-autowire="byName">
    
    	<import resource="spring-service.xml" />
    </beans>

     spring-service.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans" 
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:context="http://www.springframework.org/schema/context"
    	xsi:schemaLocation="
    	    http://www.springframework.org/schema/beans
    	    http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
    	    http://www.springframework.org/schema/context
    	    http://www.springframework.org/schema/context/spring-context-3.2.xsd"
        default-autowire="byName">
    
        <context:component-scan base-package="com.itlong.whatsmars.fs.web.service" />
    
        <bean id="mongodbProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
            <property name="locations">
                <list>
                    <value>classpath:mongodb-config.properties</value>
                </list>
            </property>
        </bean>
    
        <bean id="mongodbDriver" class="com.itlong.whatsmars.common.mongo.object.MongoDBDriver" init-method="init" destroy-method="close">
            <property name="properties" ref="mongodbProperties"/>
            <property name="configuration">
                <bean class="com.itlong.whatsmars.common.mongo.object.MongoDBConfig">
                    <property name="addresses" value="${whatsmars.mongodb.filesystem.addresses}"/>
                    <property name="credentials">
                        <list>
                            <bean class="com.itlong.whatsmars.common.mongo.object.MongoDBCredential">
                                <property name="databaseName" value="${whatsmars.mongodb.filesystem.dbname}"/>
                                <property name="username" value="${whatsmars.mongodb.filesystem.username}"/>
                                <property name="password" value="${whatsmars.mongodb.filesystem.password}"/>
                            </bean>
                        </list>
                    </property>
    
                </bean>
    
            </property>
        </bean>
    
        <bean id="gridFSClient" class="com.itlong.whatsmars.common.mongo.GridFSClient">
            <property name="mongoDBDriver" ref="mongodbDriver"/>
            <property name="databaseName" value="${whatsmars.mongodb.filesystem.dbname}"/>
        </bean>
    
    </beans>

     spring-mvc-servlet.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:context="http://www.springframework.org/schema/context"
           xmlns:mvc="http://www.springframework.org/schema/mvc"
           xsi:schemaLocation="http://www.springframework.org/schema/beans
               http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
               http://www.springframework.org/schema/context
    	       http://www.springframework.org/schema/context/spring-context-3.2.xsd
    	       http://www.springframework.org/schema/mvc
    	       http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd">
    
        <mvc:annotation-driven>
            <mvc:message-converters>
                <bean class="org.springframework.http.converter.StringHttpMessageConverter">
                    <property name = "supportedMediaTypes">
                        <list>
                            <value>text/plain;charset=UTF-8</value>
                            <value>text/html;charset=UTF-8</value>
                        </list>
                    </property>
                </bean>
    
            </mvc:message-converters>
        </mvc:annotation-driven>
        <context:component-scan base-package="com.itlong.whatsmars.fs.web.controller" />
    
    
        <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping"/>
        <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter"/>
    
        <bean id="exceptionResolver" class="ExceptionHandler"/>
    
    </beans>
    

     

    @Controller
    public class FileController {
    
        private static final int SIZE = 1028576;//1M
    
        @Autowired
        private FileService fileService;
    
        @RequestMapping("/file_upload")
        @ResponseBody
        public String uploadFile(@RequestParam(value = "format",required = false)String format,
                                 @RequestParam(value = "uid")String uid,
                                 @RequestParam("token")String token,
                                 HttpServletRequest request) {
    
            String source = DESUtils.decrypt(token, CommonConstants.FS_SECURITY_KEY);
            if(!source.equals(uid)) {
                return ResultHelper.renderAsJson(ResultCode.VALIDATE_FAILURE);
            }
            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            try {
                InputStream inputStream = request.getInputStream();//body inputstream
                if (inputStream == null) {
                    return ResultHelper.renderAsJson(ResultCode.PARAMETER_ERROR);
                }
                int i = 0;
                int maxSize = SIZE * 32;//最大32M
                while (true) {
                    int _c = inputStream.read();
                    if (_c == -1) {
                        break;
                    }
                    bos.write(_c);
                    i++;
                    if (i > maxSize) {
                        inputStream.close();
                        bos.close();
                        return ResultHelper.renderAsJson(ResultCode.VALIDATE_FAILURE, "文件尺寸超过最大限制");
                    }
                }
                inputStream.close();
            } catch (Exception e) {
                return ResultHelper.renderAsJson(ResultCode.SYSTEM_ERROR);
            }
    
            //
            ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
            Result result = this.fileService.uploadFile(bis, format,uid);
            return ResultHelper.renderAsJson(result);
        }
    
    
        @RequestMapping("/image_upload")
        @ResponseBody
        public String uploadImage(@RequestParam("token")String token,
                                  @RequestParam("uid")String uid,
                                  @RequestParam(value = "return_size",required = false)Integer returnSize,
                                  HttpServletRequest request) {
    
            String source = DESUtils.decrypt(token, CommonConstants.FS_SECURITY_KEY);
            if(!source.equals(uid)) {
                return ResultHelper.renderAsJson(ResultCode.VALIDATE_FAILURE);
            }
    
            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            try {
                InputStream inputStream = request.getInputStream();//body inputstream
                if (inputStream == null) {
                    return ResultHelper.renderAsJson(ResultCode.PARAMETER_ERROR);
                }
                int i = 0;
                int maxSize = 6 * SIZE;//最大6M
                while (true) {
                    int _c = inputStream.read();
                    if (_c == -1) {
                        break;
                    }
                    bos.write(_c);
                    i++;
                    if (i > maxSize) {
                        inputStream.close();
                        bos.close();
                        return ResultHelper.renderAsJson(ResultCode.VALIDATE_FAILURE, "文件尺寸超过最大限制");
                    }
                }
                inputStream.close();
            } catch (Exception e) {
                return ResultHelper.renderAsJson(ResultCode.SYSTEM_ERROR);
            }
    
            //
            ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
            Result result = this.fileService.uploadImage(bis,uid,returnSize);
            return ResultHelper.renderAsJson(result);
        }
    
        @RequestMapping("/ds/{filename}")
        @ResponseBody
        public void displayFile(@PathVariable("filename")String filename,HttpServletResponse response) {
            Result result = this.fileService.displayFile(filename);
            if(result.isSuccess()) {
                InputStream stream = (InputStream)result.getModel("inputStream");
                try {
                    OutputStream outputStream = response.getOutputStream();
                    if (stream != null) {
                        BufferedInputStream bis = new BufferedInputStream(stream, 128);
                        while (true) {
                            int _current = bis.read();
                            if (_current < 0) {
                                break;
                            }
                            outputStream.write((byte) _current);
                        }
                    }
                } catch (Exception e) {
                    //
                } finally {
                    try {
                        stream.close();
                    }catch (Exception e) {
                        //
                    }
                }
            }
        }
    
        @RequestMapping("/ds/{path}/{filename}")
        @ResponseBody
        public void displayImage(@PathVariable("filename")String filename,
                                 @PathVariable("path")String path,
                                 HttpServletResponse response) {
    
            Result result = this.fileService.displayImage(filename,path);
            if(result.isSuccess()) {
                InputStream stream = (InputStream)result.getModel("inputStream");
                try {
                    OutputStream outputStream = response.getOutputStream();
                    if (stream != null) {
                        BufferedInputStream bis = new BufferedInputStream(stream, 128);
                        while (true) {
                            int _current = bis.read();
                            if (_current < 0) {
                                break;
                            }
                            outputStream.write((byte) _current);
                        }
                    }
    //                String timestamp = (String)result.getModel("timestamp");
    //                if(timestamp != null) {
    //                    response.addDateHeader("Last-Modified",Long.valueOf(timestamp));
    //                }
                } catch (Exception e) {
                    //
                } finally {
                    try {
                        stream.close();
                    }catch (Exception e) {
                        //
                    }
                }
            }
        }
    
    }

     

    public interface FileService {
    
        /**
         * 上传文件,制定文件的格式
         * @param inputStream 输入流
         * @Param format 文件格式后缀
         * @param uid 文件上传者
         *
         */
        public Result uploadFile(InputStream inputStream, String format, String uid);
    
        /**
         * 图片上传
         * @param inputStream
         * @param returnSize 返回接近此size的url全路径
         */
        public Result uploadImage(ByteArrayInputStream inputStream, String uid, Integer returnSize);
    
        /**
         * 删除文件
         * @param filename
         * @return
         */
        public Result delete(String filename);
    
        /**
         * 获取文件
         * @param filename
         * @return
         */
        public Result displayFile(String filename);
    
        public Result displayImage(String filename, String path);
    }

     

    @Service
    public class FileServiceImpl implements FileService {
    
        protected static final Logger logger = Logger.getLogger(FileService.class);
    
        @Autowired
        private GridFSClient gridFSClient;
    
        @Override
        public Result uploadFile(InputStream inputStream, String format,String uid) {
            Result result = new Result();
            try {
                String filename = gridFSClient.saveFile(inputStream,format,uid);
                result.addModel("filename",filename);
                result.setSuccess(true);
            } catch (Exception e) {
                logger.error("upload file error,",e);
                result.setResultCode(ResultCode.SYSTEM_ERROR);
                result.setMessage("文件上传失败");
            }
            return result;
        }
    
        @Override
        public Result uploadImage(ByteArrayInputStream inputStream,String uid,Integer returnSize) {
            Result result = new Result();
            try {
                String filename = gridFSClient.saveImage(inputStream,uid);
                result.addModel("filename",filename);
    
                if(returnSize != null && returnSize > 0) {
                    //找出符合returnSize的path
                    for (ImageSizeEnum e : ImageSizeEnum.values()) {
                        if (e.size >= returnSize) {
                            result.addModel("uri",e.path + "/" + filename);
                        }
                    }
                    //返回最大尺寸
                    result.addModel("uri",ImageSizeEnum.PIXELS_MAX.path + "/" + filename);
                }
                result.setSuccess(true);
            } catch (Exception e) {
                logger.error("upload image error,",e);
                result.setResultCode(ResultCode.SYSTEM_ERROR);
                result.setMessage("图片上传失败");
            }
            return result;
        }
    
        @Override
        public Result delete(String filename) {
            Result result = new Result();
            try {
                gridFSClient.delete(filename);
                result.addModel("filename",filename);
                result.setSuccess(true);
            } catch (Exception e) {
                logger.error("delete file error,",e);
                result.setResultCode(ResultCode.SYSTEM_ERROR);
                result.setMessage("文件删除失败");
            }
            return result;
        }
    
        @Override
        public Result displayImage(String filename,String path) {
            Result result = new Result();
            try {
                InputStream inputStream = gridFSClient.getImage(filename,path);
                if(inputStream != null) {
                    result.addModel("inputStream", inputStream);
                    result.setSuccess(true);
                }
            } catch (Exception e) {
                result.setResultCode(ResultCode.SYSTEM_ERROR);
            }
            return result;
        }
    
    
        @Override
        public Result displayFile(String filename) {
            Result result = new Result();
            try {
                InputStream inputStream = gridFSClient.getFile(filename);
                if(inputStream != null) {
                    result.addModel("inputStream", inputStream);
                    result.setSuccess(true);
                }
            } catch (Exception e) {
                result.setResultCode(ResultCode.SYSTEM_ERROR);
            }
            return result;
        }
    }

     

    代码见 https://github.com/javahongxi/whatsmars/tree/1.0/whatsmars-earth/whatsmars-earth-support-web

    展开全文
  • MongoDB存储图片和读取图片

    千次阅读 2016-08-26 18:29:00
    1、存储图片 // 存储文件信息 GridFS gridFS = new GridFS(MongoDBUtil.getDB(), "test"); File localFile = new File("d://test.jpg"); GridFSInputFile oneFile = gridFS.createFile(localFile); oneFile....

    1、存储图片

    // 存储文件信息
    GridFS gridFS = new GridFS(MongoDBUtil.getDB(), "test");
    File localFile = new File("d://test.jpg");
    GridFSInputFile oneFile = gridFS.createFile(localFile);
    oneFile.setFilename("test.jpg");
    
    
    // 配置文件属性
    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
    BasicDBObject metadata = new BasicDBObject();
    metadata.put("uploadDate", df.format(new Date()));
    oneFile.setMetaData(metadata);	//添加属性
    oneFile.save();	//保存文件
    

    2、根据文件ID读取图片

    // 存储文件信息
    GridFS gridFS = new GridFS(MongoDBUtil.getDB(), "test");
    // 读取文件
    GridFSDBFile outFile = gridFS.findOne(new ObjectId(request.getParameter("id")));
    //System.out.println(outFile);
    

    3、根据MetaData属性查找图片

    // 
    GridFS gridFS = new GridFS(MongoDBUtil.getDB(), "test");
    //查找条件  
    BasicDBObject query = new BasicDBObject("metadata.pkid", "1123");
    List<GridFSDBFile> listFiles = gridFS.find(query);
    System.out.println(listFiles);
    System.out.println(listFiles.size());

    4、显示图片

        @RequestMapping(value = "/show")  
        public void show(HttpServletRequest request, HttpServletResponse response){
    		try {
    			OutputStream out = response.getOutputStream();
    			response.setContentType("image/jpg");
    			GridFS gridFS = new GridFS(MongoDBUtil.getDB(), "test");
    			// 读取文件
    			GridFSDBFile outFile = gridFS.findOne(new ObjectId(request.getParameter("id")));
    			//System.out.println(outFile);
    			if(outFile!=null){
    				outFile.writeTo(out);
    				out.flush();
    				out.close();
    			}
    		} catch (Exception e) {
    			e.printStackTrace();
    		}
    	}

     

    转载于:https://my.oschina.net/zhxm/blog/738467

    展开全文
  • 主要介绍了java+MongoDB实现存图片、下载图片的方法,结合实例形式详细分析了java结合MongoDB实现图片存储与下载相关操作技巧,需要的朋友可以参考下
  • Django项目 | 使用MongoDB存储图片

    千次阅读 2018-12-19 23:01:29
    最近要做一个使用mongodb做数据库的django项目,需要利用其存储图片。在django中使用mongoengine作为调用mongodb数据库的方法。探索了一下如何存放图片,记录在这里,但是肯定有更好的解决办法,希望有了解的人指点...

    最近要做一个使用mongodb做数据库的django项目,需要利用其存储图片。在django中使用mongoengine作为调用mongodb数据库的方法。探索了一下如何存放图片,记录在这里,但是肯定有更好的解决办法,希望有了解的人指点一下~
    首先在晚上百度了一下,找到了很多办法,但是在试的过程中出现了很多问题,浪费了很多时间,最后还是在mongoengine官方文档找到了答案。

    mongodb使用GridFS存储和检索大文件,如图片、音频文件、视频文件等。这是一种文件系统,用来存储文件,但数据存储于MongoDB的集合中。GridFS存储文件比其文档大小16MB限制的更大能力。GridFS
    会将大文件对象分割成多个小的chunk(文件片段),一般为256k/个,每个chunk将作为MongoDB的一个文档(document)被存储在chunks集合中。
    GridFS默认使用两个集合 fs.files 和 fs.chunks 存储该文件的元数据和块。每组块标识其唯一的_id
    ObjectID字段。fs.files切断作为父文件。 fs.chunks 文档 files_id 字段链接块到其父文件。

    在django中可以这样实现:
    在这里插入图片描述

    然后就照着官方文档来啦:

    • 首先在models.py中创建数据模型

      class UserInfor(mongoengine.Document):
      userId = mongoengine.IntField(default=0)
      img = mongoengine.FileField()
      time = mongoengine.DateTimeField(default=datetime.datetime.now)

    • 然后可以在views.py中编写用于存放图片的方法。

      imgtmp = open(’./static/goodsImage/cosmos.jpg’, ‘rb’)
      temp = UserInfor(userId=userId)
      temp.img.put(imgtmp, content_type=‘image/jpeg’)
      temp.save()

    其中存入图片需要采用put()的方式,这样就成功保存了。看一下效果:
    首先在我们原数据库集合里里多出了刚刚存放的文档:

    {
        "_id": "5c1685fb10bf2143e8347174",
        "userId": 0,
        "img": "5c1685fb10bf2143e8347172",
        "time": "2018-12-17T01:06:03.136Z"
    }
    

    其次数据库里多出了两个集合:
    在这里插入图片描述
    fs.files中的文档为:

    {
        "_id": "5c1685fb10bf2143e8347172",
        "contentType": "image/jpeg",
        "md5": "6492f052302b31167ff19c9dc72998df",
        "chunkSize": 261120,
        "length": 9569,
        "uploadDate": "2018-12-16T17:06:03.146Z"
    }
    

    fs.chunks中的文档为:

    {
        "_id": "5c1685fb10bf2143e8347173",
        "files_id": "5c1685fb10bf2143e8347172",
        "n": 0,
        "data": "/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAA0JCgsKCA0LCgsODg0PEyAVExISEyccHhcgLikxMC4pLSwzOko+MzZGNywtQFdBRkxOUlNSMj5aYVpQYEpRUk//2wBDAQ4ODhMREyYVFSZPNS01T09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0//wAARCAEsAeEDASIAAhEBAxEB/8QAGwAAAgMBAQEAAAAAAAAAAAAAAAIBAwQFBgf/xAA3EAACAgECBQMDAgUDBAMBAAAAAQIRAwQhBRIxQVETYZEGUnEigRQyQqGxI4LBM1PR8BUWQ3L/xAAZAQEBAQEBAQAAAAAAAAAAAAAAAQIDBAX/xAAfEQEBAQEBAAMBAQEBAAAAAAAAARECIQMxQRJRImH/2gAMAwEAAhEDEQA/AMqxw+yPwSscPsj8DpAlufVx49R6cfsj8B6cPsj8D0FDIaT04fZH4J9OH2R+BkhqCbSenD7I/BPpwv8Akj8DAPDS8kPtXwg9OH2r4QxNA0npw+yPwMscH/TH4JSGSFCrHD7I/CBY4L+iPwh0gZEQowT/AJI/CG9OEl/JH4QJEpkCPHBf0R+EQscPsj8IuSTFap7BdJ6cPsj8Iza6EFp21BdfBsoza9JaWVi+Sk+3ISUZqSS+Dp6SePJGnGNr2RyoS5k0/wBi/S5HjzJ9jy251Oo7Zssdh44fZH4QPHB/0L4RKadU0NR6p764ewnpx+yPwg9OH2R+EPQJeShPTh9kfhAscPsj8IegoYuk9OH2x+EHpw+2PwiwgZE9IscF/RH4QenD7I/CHoKGGk9OH2x+EHpx+yPwh6Chgr9OP2R+ET6cPtj8IeiKGGk9OH2R+EHpw+2Pwh6CiYK3jh9kfhAscPsj8FgC4K/Tj9kfgPTh9kfhFhFDIE9OH2R+EHpwX9EfhDhQXVfpw+yPwQ8cL/kj8FtexDXgEqv04fZ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3aF8uog/DX+Swr38dopeEiSE04p+UmFlcqkE9yLoAQ1ghQAa9yJxjkg4zScWqaatNEWDe4Ned4r9O3eXRK11eN9f2POSwSx5HGcWmnTTXQ+i37mPW8O0+ti3kjU+0l1/fyTPWp08LkxeEUOFdj0Ot4Rn06ba54dpRX/tHKyYGm7TFalYXEimaHjafQV49+giq02hkS4UyKaZQyYyYqZKJosUmujOrwzjWbStQyt5MXhvdfg46GQMe/wBLqcOrxLJhmmu67r2ZbR4TSazNpMinhm4vuuz/ACem4dxvFqmseZLHley8MsrNjq0BFryBUwq2YyFRKIiQlJRi5N0l3AwcXyShpqi6vqNJHO1uoefO2n+lbJGLI2l5Lv6SqfRnO/bpJ452pSbUkq7MzVRvzxVPYxd2WKVEoEMluVEwi20dzg2gefIpyX6I7u+5ztHCMpLmV7nsdDjjj0sVBUtipa0JKKSSpLZImwIEc0tkWAFE2YeM6dajRNpXOG6/Hc2kpKUWnumiRXz/ADRpszSW50+IwjDUzjFUk3Rz59RW4oZHcd9Re4VDRDQzIfQCEr2Rrxx5YpfJTgSc1+DUjNWHgi1LYriWLoYEpU7GSsUsQVFJCtJjvqI+oRXNVZkz4uZc8Vv3NkitifY5zQKPuW5YpTdIVI6RBGJowPlmn4ZUi2C3RR73RZFl0eGad3BfNF1HN+npOXDY8zupNI6ZXKzEUFEg+g0RQUCAAoKDuSArJB9QQEPdU1aMep4ZptQm3BQl5RtZHcG483q+A5oJvDU11pdTkZdNPFJqcGmuzVHuynNp8OpfJmxxkvPcmNSvCSx+xXKDSO3xDSYsOVxgml+TmziqewajDT8DK66DtLcVdQoC66sGLFKTfNuBPqRT6t/geGVJpptMaMUlsgpMYa0//I5/+/L5Ay8kfAAf/9k="
    }
    

    三个文档由同一个_id联系在一起,图片的实际内容被存在chunks(二进制数据)中,和图片有关的meta数据(filename,content_type,还有用户自定义的属性)被存在files集合中。
    其他类型文件的存放应该也是类似。

    那么怎么将图片数据取出来,让前端可以通过ajax请求得到数据并展示在前端呢?

    对于grifs存放的文件的读取,mongoengine的文档也做了详细的说明:
    在这里插入图片描述
    下面是我当时写的一个例子,其实只要照着文档做就好了

    userinfor= UserInfor.objects(userId=userId).first()
    photo = userinfor.img.read()
    #content_type = userinfor.test.content_type
    response = HttpResponse(photo)
    response['Content-Type'] = 'application/octet-stream'
    response['Content-Disposition'] = 'attachment;filename="cosmos.jpg"'
    return response
    

    这里是通过二进制流的方式向前端发送图片,下面是vue.js的前端部分:

    getInfor() {
      var that =this
      this.$axios({
        method: 'post',
        url: 'http://127.0.0.1:8000/getinfor/',
        headers: {
          'Content-type': 'application/x-www-form-urlencoded'
        },
        data: Qs.stringify(
          {
            userId: 0,
          }
        ),
        responseType: 'arraybuffer'
      }).then((res) => {
        console.log(res.data)
        #将图片转换成base64格式,以在页面显示
        return 'data:image/png;base64,' + btoa(
          new Uint8Array(res.data)
            .reduce((data, byte) => data + String.fromCharCode(byte), '')
        )
      }).then(function (data) {
        保存转换后的Base64图片
        console.log(data)
        that.imgUrl = data
      }).catch((error) => {
        console.log(error)
      })
    }
    

    这样imgUrl里保存的就是base64格式的图片信息了,大致是这种样子:

    data:image/png;base64,/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAA0JCgsKCA0LCgsODg0PEyAVExISEyccHhcgLikxMC4pLSwzOko+MzZGNywtQFdBRkxOUlNSMj5aYVpQYEpRUk//2wBDAQ4ODhMREyYVFSZPNS01T09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0//wAARCAEsAeEDASIAAhEBAxEB/8QAGwAAAgMBAQEAAAAAAAAAAAAAAAIBAwQFBgf/xAA3EAACAgECBQMDAgUDBAMBAAAAAQIRAwQhBRIxQVETYZEGUnEigRQyQqGxI4LBM1PR8BUWQ3L/xAAZAQEBAQEBAQAAAAAAAAAAAAAAAQIDBAX/xAAfEQEBAQEBAAMBAQEBAAAAAAAAARECIQMxQRJRImH/2gAMAwEAAhEDEQA/AMqxw+yPwSscPsj8DpAlufVx49R6c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re4VDRDQzIfQCEr2Rrxx5YpfJTgSc1+DUjNWHgi1LYriWLoYEpU7GSsUsQVFJCtJjvqI+oRXNVZkz4uZc8Vv3NkitifY5zQKPuW5YpTdIVI6RBGJowPlmn4ZUi2C3RR73RZFl0eGad3BfNF1HN+npOXDY8zupNI6ZXKzEUFEg+g0RQUCAAoKDuSArJB9QQEPdU1aMep4ZptQm3BQl5RtZHcG483q+A5oJvDU11pdTkZdNPFJqcGmuzVHuynNp8OpfJmxxkvPcmNSvCSx+xXKDSO3xDSYsOVxgml+TmziqewajDT8DK66DtLcVdQoC66sGLFKTfNuBPqRT6t/geGVJpptMaMUlsgpMYa0//I5/+/L5Ay8kfAAf/9k=
    

    把这个直接给标签的src赋值就可以显示图片了,也可以直接把上面一段粘贴在浏览器地址栏查看。

    <img src="data:image/png;base64,/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAA0JCgsKCA0LCgsODg0PEyAVExISEyccHhcgLikxMC4pLSwzOko+MzZGNywtQFdBRkxOUlNSMj5aYVpQYEpRUk//2wBDAQ4ODhMREyYVFSZPNS01T09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0//wAARCAEsAeEDASIAAhEBAxEB/8QAGwAAAgMBAQEAAAAAAAAAAAAAAAIBAwQFBgf/xAA3EAACAgECBQMDAgUDBAMBAAAAAQIRAwQhBRIxQVETYZEGUnEigRQyQqGxI4LBM1PR8BUWQ3L/xAAZAQEBAQEBAQAAAAAAAAAAAAAAAQIDBAX/xAAfEQEBAQEBAAMBAQEBAAAAAAAAARECIQMxQRJRImH/2gAMAwEAAhEDEQA/AMqxw+yPwSscPsj8DpAlufVx49R6cfsj8B6cPsj8D0FDIaT04fZH4J9OH2R+BkhqCbSenD7I/BPpwv8Akj8DAPDS8kPtXwg9OH2r4QxNA0npw+yPwMscH/TH4JSGSFCrHD7I/CBY4L+iPwh0gZEQowT/AJI/CG9OEl/JH4QJEpkCPHBf0R+EQscPsj8IuSTFap7BdJ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Eg+g0RQUCAAoKDuSArJB9QQEPdU1aMep4ZptQm3BQl5RtZHcG483q+A5oJvDU11pdTkZdNPFJqcGmuzVHuynNp8OpfJmxxkvPcmNSvCSx+xXKDSO3xDSYsOVxgml+TmziqewajDT8DK66DtLcVdQoC66sGLFKTfNuBPqRT6t/geGVJpptMaMUlsgpMYa0//I5/+/L5Ay8kfAAf/9k=">
    
    展开全文
  • 1.model.py文件 class Animal(mongoengine.Document): genus = mongoengine.StringField(max_length=16) family = mongoengine.String...2.view.py文件(存储图片) class CompanyImage(View): def get(self.
  • MongoDB(三)——图片存储

    千次阅读 2019-09-15 20:27:03
    图片存储的两种思路和方法 方法一、 直接将图片的base64编码存在MongoDB数据库中 Base64是一种用64个字符来表示任意二进制数据的方法,常用于在URL、Cookie、网页中传输少量二进制数据。 前台 绑定input的change...
  • Python操作MongoDB进行文件存储

    千次阅读 2020-09-01 14:26:31
    图片、文档等存入mogodb中,需要用到两个模块,pymongo和gridfs,在存入过程中必须将文件转换为二进制的格式才能存入,存入mongoDB中会生成两个文件xxx.chunk 和xxx.files。 GridFS是一种将大型文件存储MongoDB...
  • mongodb保存图片的两种方法

    万次阅读 2018-07-28 23:15:11
    #存储图片 outf. close () if num % 100000 == 0 metadata_file = open ( "/home/metadata%d.csv" %( num / 100000 + 1 ), "ab" ) csv_writer = csv.writer(metadata_file,delimiter= '\t' ) row = ...
  • SpringBoot+MongoDB 实现图片存取

    千次阅读 2019-04-25 16:40:57
    目录添加 MongoDB 依赖并配置建立图片实体上传图片获取图片结果 最近要实现一个发布博客功能,涉及到博文中图片的保存与访问了,在博文中图片对应:![图片描述](图片url)。由用户上传图片,我们将其保存在 mongodb ...
  • 用spring boot写的一个WEBSOCKET发广播和点对点,以及整合了mongoDB存文件,使用的是GridFS,也包含了非GRIDFS存文件但是大小有限制16M
  • 先介绍下mongodb的基本操作及使用 第一部:开启安全性验证 如果需要给MongoDB数据库使用安全验证,则需要用--auth开启安全性检查,则只有数据库认证的用户才能执行读写操作,开户安全性检查,有两种方式: 第一种...
  • SpringBoot配置MongoDB实现文件存储

    千次阅读 2019-09-09 17:26:44
    1.官网下载MongoDB,下载完运行mongod服务 我的资源地址:https://download.csdn.net/download/rexueqingchun/11704418 2.application.properties配置MongoDB连接 #mongodb spring.data.mongodb.uri=mongodb://...
  • java+MongoDB实现存图片、下载图片

    千次阅读 2018-12-11 17:29:33
    1.存图片 demo:将某个文件存到mongoDB,这个file可以通过前台参数传入,我这里直接将D://test.png存到mongoDB @RequestMapping("/addFile") @ResponseBody public String addFile(){ MongoClient ...
  • 导入图片 引入模块,其中gridfs模块不需要单独安装,引入了pymongo即可直接引入 ...#链接mongodb client=MongoClient('localhost',27017) #取得对应的collection db=client.image #本地硬盘上的图片...
  • MongoDB 存储图片等文件有两种方式 (该文章针对的是已经可以使用MONGODB整合Spring的用户) 相关阅读: MongoDB备份与恢复 http://www.linuxidc.com/Linux/2012-07/64113.htm CentOS编译安装MongoDB
  • @Value("${spring.data.mongodb.database}") String db; @Bean public GridFSBucket getGridFSBucket(MongoClient mongoClient) { MongoDatabase database = mongoClient.getDatabase(db); GridFSBucke
  • MongoDB : 数据库 开发工具: IDEA 2020.3.2 Postman Spring Boot 连接 MongoDB 相关配置: https://blog.csdn.net/LZW15082682930/article/details/114678505 方法二 承接上文,有关MongoDB配置转到...
  • 利用mongodb实现分布式WEB图片存储

    千次阅读 2016-08-30 14:38:28
    利用mongodb实现分布式WEB图片存储 2012-12-22 14:00:33 标签:mongodb 分布式图片存储 nginx 分布式网站  。 的确在站比较小得时候,附件不多的时候,当然这样处理很好。但是当 附件数量海里去了~~ 那...
  • Python 实现MongoDB Gridfs图片存取

    千次阅读 2019-03-20 10:27:19
    Python 实现MongoDB Gridfs图片存取 Gridfs官方文档链接:http://api.mongodb.com/python/current/api/gridfs/index.html?highlight=gridfs#module-gridfs # -*- coding:utf-8 -*- from gridfs import GridFS ...
  • 需求: 客户端批量上传图片到服务器,服务器返回图片链接 用到的主要工具及node库有 multer mongoose 代码如下 var router = require('express').Router() var projectInfo = require('../projectInfo.json') var ...
  • NULL 博文链接:https://chwshuang.iteye.com/blog/2065974
  • 本篇文章主要介绍了nodejs实现本地上传图片并预览功能(express4.0+) ,具有一定的参考价值,有兴趣的可以了解一下

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 24,238
精华内容 9,695
关键字:

mongodb存储图片