Hello!
I need to allow users attach *.doc files to quotations (one file per quotation). I've made this modification but it seems that my algorithm for Web too slowly (uploading time for file with size ~100 KB is near 3 minutes thru intranet). May be there is another more quickly algorithm for uploading file?
Please note that it will be necessary to store uploaded file in backend database not at disk and file will be opened in backend (SAP CRM).
I'm working with CRM B2B 5.0
Here is my code:
InputStream stream = null;
String fileName = null;
String inputCharset = "windows-1251";
String actualCharset = LocaleUtil.getEncoding(LocaleUtil.getSAPLang(request));
if(!CodePageUtils.isUnicodeEncoding()) {
inputCharset = actualCharset;
}
try {
FormFile file = ((UploadForm)form).getChosenFile();
fileName = file.getFileName();
fileName = LocaleUtil.encodeString(fileName, inputCharset, actualCharset);
String contentType = file.getContentType();
contentType = LocaleUtil.encodeString(contentType, inputCharset, actualCharset);
String size = ""+file.getFileSize();
if(file == null) {
ActionForward actionforward = new ActionForward("upload_error");
return actionforward;
}
String strByte = new String();
String hexData = new String();
// byte stream
try{
stream = (FileInputStream)file.getInputStream();
}catch(Exception e){
stream = (ByteArrayInputStream) file.getInputStream();
}
int tmp_int;
while( (tmp_int = stream.read()) != -1){
strByte = Integer.toHexString(tmp_int).toUpperCase();
if(strByte.length()>2)
strByte = strByte.substring(6,strByte.length());
else if (strByte.length() == 1)
strByte = "0"+strByte;
hexData += strByte;
}
...
hexData contain all file in binary representation.
Regards, Lev