Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MediaType.TEXT_CSV for Jersey

Tags:

jersey

Would it be possible to accept csv types? service.path(appPath).accept(mediaType).get(String.class)

There's no MediaType.TEXT_CSV defined in javax.ws.rs.core.MediaType. Have I missed something?

I am currently on Jersey 1.1.6.

Many thanks.

like image 967
anNA Avatar asked Jan 25 '13 11:01

anNA


2 Answers

You could define your own media type:

public final static String TEXT_CSV = "text/csv";
public final static MediaType TEXT_CSV_TYPE = new MediaType("text", "csv");
like image 79
condit Avatar answered Oct 30 '22 10:10

condit


csv is nothing but comma seperated text file

you can always use text\plain as media type to deal with CSV files - and deal with the CSV using frameworks such as Open CSV.

Or (in case of fileupload)

@Consumes(MediaType.MULTIPART_FORM_DATA)
public String process(@FormDataParam("file") InputStream csv) throws IOException {
//Process CSV file
}
like image 4
TheWhiteRabbit Avatar answered Oct 30 '22 11:10

TheWhiteRabbit