Search in sources :

Example 16 with FileNameMap

use of java.net.FileNameMap in project portal by ixinportal.

the class OkHttpClientManager method guessMimeType.

// ****************************
// private Request buildMultipartFormRequest(String url, File[] files,
// String[] fileKeys, Param[] params)
// {
// //        params = validateParam(params);
// 
// MultipartBody.Builder builder = new MultipartBody.Builder()
// .setType(MultipartBody.FORM);
// 
// for (Param param : params)
// {
// builder.addPart(Headers.of("Content-Disposition", "form-data; name=\"" + param.key + "\""),
// RequestBody.create(null, param.value));
// }
// if (files != null)
// {
// RequestBody fileBody = null;
// for (int i = 0; i < files.length; i++)
// {
// File file = files[i];
// String fileName = file.getName();
// fileBody = RequestBody.create(MediaType.parse(guessMimeType(fileName)), file);
// //TODO 根据文件名设置contentType
// builder.addPart(Headers.of("Content-Disposition",
// "form-data; name=\"" + fileKeys[i] + "\"; filename=\"" + fileName + "\""),
// fileBody);
// }
// }
// 
// RequestBody requestBody = builder.build();
// return new Request.Builder()
// .url(url)
// .post(requestBody)
// .build();
// }
private String guessMimeType(String path) {
    FileNameMap fileNameMap = URLConnection.getFileNameMap();
    String contentTypeFor = fileNameMap.getContentTypeFor(path);
    if (contentTypeFor == null) {
        contentTypeFor = "application/octet-stream";
    }
    return contentTypeFor;
}
Also used : FileNameMap(java.net.FileNameMap)

Example 17 with FileNameMap

use of java.net.FileNameMap in project portal by ixinportal.

the class OkHttpClientManagerCallback method guessMimeType.

// ****************************
// private Request buildMultipartFormRequest(String url, File[] files,
// String[] fileKeys, Param[] params)
// {
// //        params = validateParam(params);
// 
// MultipartBody.Builder builder = new MultipartBody.Builder()
// .setType(MultipartBody.FORM);
// 
// for (Param param : params)
// {
// builder.addPart(Headers.of("Content-Disposition", "form-data; name=\"" + param.key + "\""),
// RequestBody.create(null, param.value));
// }
// if (files != null)
// {
// RequestBody fileBody = null;
// for (int i = 0; i < files.length; i++)
// {
// File file = files[i];
// String fileName = file.getName();
// fileBody = RequestBody.create(MediaType.parse(guessMimeType(fileName)), file);
// //TODO 根据文件名设置contentType
// builder.addPart(Headers.of("Content-Disposition",
// "form-data; name=\"" + fileKeys[i] + "\"; filename=\"" + fileName + "\""),
// fileBody);
// }
// }
// 
// RequestBody requestBody = builder.build();
// return new Request.Builder()
// .url(url)
// .post(requestBody)
// .build();
// }
private String guessMimeType(String path) {
    FileNameMap fileNameMap = URLConnection.getFileNameMap();
    String contentTypeFor = fileNameMap.getContentTypeFor(path);
    if (contentTypeFor == null) {
        contentTypeFor = "application/octet-stream";
    }
    return contentTypeFor;
}
Also used : FileNameMap(java.net.FileNameMap)

Example 18 with FileNameMap

use of java.net.FileNameMap in project portal by ixinportal.

the class OkHttpClientManagerSave method guessMimeType.

// ****************************
// private Request buildMultipartFormRequest(String url, File[] files,
// String[] fileKeys, Param[] params)
// {
// //        params = validateParam(params);
// 
// MultipartBody.Builder builder = new MultipartBody.Builder()
// .setType(MultipartBody.FORM);
// 
// for (Param param : params)
// {
// builder.addPart(Headers.of("Content-Disposition", "form-data; name=\"" + param.key + "\""),
// RequestBody.create(null, param.value));
// }
// if (files != null)
// {
// RequestBody fileBody = null;
// for (int i = 0; i < files.length; i++)
// {
// File file = files[i];
// String fileName = file.getName();
// fileBody = RequestBody.create(MediaType.parse(guessMimeType(fileName)), file);
// //TODO 根据文件名设置contentType
// builder.addPart(Headers.of("Content-Disposition",
// "form-data; name=\"" + fileKeys[i] + "\"; filename=\"" + fileName + "\""),
// fileBody);
// }
// }
// 
// RequestBody requestBody = builder.build();
// return new Request.Builder()
// .url(url)
// .post(requestBody)
// .build();
// }
private String guessMimeType(String path) {
    FileNameMap fileNameMap = URLConnection.getFileNameMap();
    String contentTypeFor = fileNameMap.getContentTypeFor(path);
    if (contentTypeFor == null) {
        contentTypeFor = "application/octet-stream";
    }
    return contentTypeFor;
}
Also used : FileNameMap(java.net.FileNameMap)

Example 19 with FileNameMap

use of java.net.FileNameMap in project portal by ixinportal.

the class OkHttpClientManagerSign method guessMimeType.

// ****************************
// private Request buildMultipartFormRequest(String url, File[] files,
// String[] fileKeys, Param[] params)
// {
// //        params = validateParam(params);
// 
// MultipartBody.Builder builder = new MultipartBody.Builder()
// .setType(MultipartBody.FORM);
// 
// for (Param param : params)
// {
// builder.addPart(Headers.of("Content-Disposition", "form-data; name=\"" + param.key + "\""),
// RequestBody.create(null, param.value));
// }
// if (files != null)
// {
// RequestBody fileBody = null;
// for (int i = 0; i < files.length; i++)
// {
// File file = files[i];
// String fileName = file.getName();
// fileBody = RequestBody.create(MediaType.parse(guessMimeType(fileName)), file);
// //TODO 根据文件名设置contentType
// builder.addPart(Headers.of("Content-Disposition",
// "form-data; name=\"" + fileKeys[i] + "\"; filename=\"" + fileName + "\""),
// fileBody);
// }
// }
// 
// RequestBody requestBody = builder.build();
// return new Request.Builder()
// .url(url)
// .post(requestBody)
// .build();
// }
private String guessMimeType(String path) {
    FileNameMap fileNameMap = URLConnection.getFileNameMap();
    String contentTypeFor = fileNameMap.getContentTypeFor(path);
    if (contentTypeFor == null) {
        contentTypeFor = "application/octet-stream";
    }
    return contentTypeFor;
}
Also used : FileNameMap(java.net.FileNameMap)

Example 20 with FileNameMap

use of java.net.FileNameMap in project portal by ixinportal.

the class OkHttpClientManagerTime method guessMimeType.

// ****************************
// private Request buildMultipartFormRequest(String url, File[] files,
// String[] fileKeys, Param[] params)
// {
// //        params = validateParam(params);
// 
// MultipartBody.Builder builder = new MultipartBody.Builder()
// .setType(MultipartBody.FORM);
// 
// for (Param param : params)
// {
// builder.addPart(Headers.of("Content-Disposition", "form-data; name=\"" + param.key + "\""),
// RequestBody.create(null, param.value));
// }
// if (files != null)
// {
// RequestBody fileBody = null;
// for (int i = 0; i < files.length; i++)
// {
// File file = files[i];
// String fileName = file.getName();
// fileBody = RequestBody.create(MediaType.parse(guessMimeType(fileName)), file);
// //TODO 根据文件名设置contentType
// builder.addPart(Headers.of("Content-Disposition",
// "form-data; name=\"" + fileKeys[i] + "\"; filename=\"" + fileName + "\""),
// fileBody);
// }
// }
// 
// RequestBody requestBody = builder.build();
// return new Request.Builder()
// .url(url)
// .post(requestBody)
// .build();
// }
private String guessMimeType(String path) {
    FileNameMap fileNameMap = URLConnection.getFileNameMap();
    String contentTypeFor = fileNameMap.getContentTypeFor(path);
    if (contentTypeFor == null) {
        contentTypeFor = "application/octet-stream";
    }
    return contentTypeFor;
}
Also used : FileNameMap(java.net.FileNameMap)

Aggregations

FileNameMap (java.net.FileNameMap)34 File (java.io.File)7 SimpleDateFormat (java.text.SimpleDateFormat)4 FileInputStream (java.io.FileInputStream)3 IOException (java.io.IOException)3 InputStream (java.io.InputStream)3 DigestException (com.openmeap.digest.DigestException)2 GlobalSettings (com.openmeap.model.dto.GlobalSettings)2 GenericRuntimeException (com.openmeap.util.GenericRuntimeException)2 BufferedInputStream (java.io.BufferedInputStream)2 FileNotFoundException (java.io.FileNotFoundException)2 OutputStream (java.io.OutputStream)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 Map (java.util.Map)2 Wrong (app.hongs.util.verify.Wrong)1 Category (com.agiletec.aps.system.services.category.Category)1 BaseResourceDataBean (com.agiletec.plugins.jacms.aps.system.services.resource.model.BaseResourceDataBean)1 ModelManager (com.openmeap.model.ModelManager)1 Application (com.openmeap.model.dto.Application)1 ApplicationArchive (com.openmeap.model.dto.ApplicationArchive)1