• Index
  •  » Talend Open Studio for Data Integration » Usage, Operation
  •  » how to uplaod pics into a table

#1 2012-04-23 13:25:18

querty014
Member
Registered: 2011-11-24
Posts: 13

how to uplaod pics into a table

Tags: [database, mysql]

Hi,

I have a folder which contains photos with .jpg extension. I have to upload them into a mySql table. Totally I have 2900 photos in my folder. Please help me to solve this.

Thanks,

Satya.

Offline

#2 2012-04-23 14:35:32

janhess
Member
Company: Newcastle University
Registered: 2009-05-19
Posts: 1123

Re: how to uplaod pics into a table

I have already put a couple of solutions on the forum for this.
I can't find a reference to them. I'll post it again.

Last edited by janhess (2012-04-23 15:03:58)

Offline

#3 2012-04-23 15:25:21

janhess
Member
Company: Newcastle University
Registered: 2009-05-19
Posts: 1123

Re: how to uplaod pics into a table

in the database image is defined as byte[].

I use this routine to read the image

Code:

// template routine Java
package routines;

import java.io.FileInputStream;
import java.io.File;
import java.io.FileNotFoundException;

public class ImageUtil {

    public static byte[] getByte(String filepath) {
        byte[] b=null;
        
        try {
            FileInputStream fis = new FileInputStream(filepath);
            b=new byte[fis.available()];
            fis.read(b);
        } catch (Exception e) {
            e.printStackTrace();
        }

        return b;
    }

}

Use tFileList to get a list of the file names. I iterated this to tFileProperties to get the file properties and mapped them to an output file.
this file is passed to a tMap to update the database.

Ignore the Word function in the map - it's just for formatting the person's name.


Uploaded Images

Last edited by janhess (2012-04-23 15:33:18)

Offline

  • Index
  •  » Talend Open Studio for Data Integration » Usage, Operation
  •  » how to uplaod pics into a table

Board footer

Powered by FluxBB