IDEMPIERE-763 Maximum size for File Upload.

This commit is contained in:
Heng Sin Low 2013-03-21 16:37:11 +08:00
parent a797c56caa
commit 928a75eaef
11 changed files with 43 additions and 9 deletions

View File

@ -0,0 +1,8 @@
-- Mar 21, 2013 4:18:58 PM MYT
-- IDEMPIERE-763 Maximum size for File Upload
INSERT INTO AD_SysConfig (AD_SysConfig_ID,EntityType,ConfigurationLevel,Value,Description,AD_SysConfig_UU,Created,Updated,AD_Client_ID,AD_Org_ID,CreatedBy,IsActive,UpdatedBy,Name) VALUES (200028,'D','S','5120','It specifies the maximum allowed size, in kilobytes, to upload a file from the client. A zero or negative value indicates that there is no limit.','6f5a2d67-123a-411e-a218-1c328e963cc4',TO_DATE('2013-03-21 16:18:55','YYYY-MM-DD HH24:MI:SS'),TO_DATE('2013-03-21 16:18:55','YYYY-MM-DD HH24:MI:SS'),0,0,100,'Y',100,'ZK_MAX_UPLOAD_SIZE')
;
SELECT register_migration_script('201303210824_IDEMPIERE-763.sql') FROM dual
;

View File

@ -0,0 +1,8 @@
-- Mar 21, 2013 4:18:58 PM MYT
-- IDEMPIERE-763 Maximum size for File Upload
INSERT INTO AD_SysConfig (AD_SysConfig_ID,EntityType,ConfigurationLevel,Value,Description,AD_SysConfig_UU,Created,Updated,AD_Client_ID,AD_Org_ID,CreatedBy,IsActive,UpdatedBy,Name) VALUES (200028,'D','S','5120','It specifies the maximum allowed size, in kilobytes, to upload a file from the client. A zero or negative value indicates that there is no limit.','6f5a2d67-123a-411e-a218-1c328e963cc4',TO_TIMESTAMP('2013-03-21 16:18:55','YYYY-MM-DD HH24:MI:SS'),TO_TIMESTAMP('2013-03-21 16:18:55','YYYY-MM-DD HH24:MI:SS'),0,0,100,'Y',100,'ZK_MAX_UPLOAD_SIZE')
;
SELECT register_migration_script('201303210824_IDEMPIERE-763.sql') FROM dual
;

View File

@ -528,4 +528,16 @@ public class AdempiereWebUI extends Window implements EventListener<Event>, IWeb
Executions.sendRedirect("index.zul");
}
/**
* @return string for setupload
*/
public static String getUploadSetting() {
StringBuilder uploadSetting = new StringBuilder("true,native");
int size = MSysConfig.getIntValue(MSysConfig.ZK_MAX_UPLOAD_SIZE, 0);
if (size > 0) {
uploadSetting.append(",maxsize=").append(size);
}
return uploadSetting.toString();
}
}

View File

@ -22,6 +22,7 @@ import java.util.logging.Level;
import javax.activation.DataSource;
import org.adempiere.webui.AdempiereWebUI;
import org.adempiere.webui.component.AttachmentItem;
import org.adempiere.webui.component.Button;
import org.adempiere.webui.component.ConfirmPanel;
@ -201,7 +202,7 @@ public class FeedbackRequestWindow extends Window implements EventListener<Event
Button btn = new Button();
btn.setImage(ThemeManager.getThemeResource("images/Attachment24.png"));
btn.setUpload("true");
btn.setUpload(AdempiereWebUI.getUploadSetting());
btn.addEventListener(Events.ON_UPLOAD, this);
btn.setTooltiptext(Msg.getMsg(Env.getCtx(), "Attachment"));
confirmPanel.addComponentsLeft(btn);

View File

@ -31,6 +31,7 @@ import java.sql.SQLException;
import java.util.ArrayList;
import java.util.logging.Level;
import org.adempiere.webui.AdempiereWebUI;
import org.adempiere.webui.component.Button;
import org.adempiere.webui.component.ConfirmPanel;
import org.adempiere.webui.component.Label;
@ -173,7 +174,7 @@ public class WFileImport extends ADForm implements EventListener<Event>
bFile.setLabel(Msg.getMsg(Env.getCtx(), "FileImportFile"));
bFile.setTooltiptext(Msg.getMsg(Env.getCtx(), "FileImportFileInfo"));
bFile.setUpload("true");
bFile.setUpload(AdempiereWebUI.getUploadSetting());
bFile.addEventListener(Events.ON_UPLOAD, this);
fCharset.setMold("select");

View File

@ -12,6 +12,7 @@
*****************************************************************************/
package org.adempiere.webui.component;
import org.adempiere.webui.AdempiereWebUI;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
@ -30,7 +31,7 @@ public class FilenameBox extends EditorBox
public FilenameBox()
{
super();
btn.setUpload("true");
btn.setUpload(AdempiereWebUI.getUploadSetting());
}
/**
@ -40,7 +41,7 @@ public class FilenameBox extends EditorBox
{
super();
setText(fileName);
btn.setUpload("true");
btn.setUpload(AdempiereWebUI.getUploadSetting());
}
/* (non-Javadoc)

View File

@ -21,6 +21,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.logging.Level;
import org.adempiere.webui.AdempiereWebUI;
import org.adempiere.webui.component.FilenameBox;
import org.adempiere.webui.event.ValueChangeEvent;
import org.adempiere.webui.theme.ThemeManager;
@ -49,7 +50,7 @@ public class WFilenameEditor extends WEditor
super(new FilenameBox(), gridField);
getComponent().setButtonImage(ThemeManager.getThemeResource("images/Open16.png"));
getComponent().addEventListener(Events.ON_UPLOAD, this);
getComponent().getButton().setUpload("true,native");
getComponent().getButton().setUpload(AdempiereWebUI.getUploadSetting());
getComponent().getButton().setAttribute("org.zkoss.zul.image.preload", Boolean.TRUE);
}

View File

@ -255,7 +255,7 @@ public class WAttachment extends Window implements EventListener<Event>
bLoad.setSclass("action-button");
bLoad.setAttribute("org.zkoss.zul.image.preload", Boolean.TRUE);
bLoad.setTooltiptext(Msg.getMsg(Env.getCtx(), "Load"));
bLoad.setUpload("true");
bLoad.setUpload(AdempiereWebUI.getUploadSetting());
bLoad.addEventListener(Events.ON_UPLOAD, this);
bDelete.setImage(ThemeManager.getThemeResource("images/Delete24.png"));

View File

@ -187,7 +187,7 @@ public class FileImportAction implements EventListener<Event>
hb = new Hbox();
bFile.setLabel(Msg.getMsg(Env.getCtx(), "FileImportFile"));
bFile.setTooltiptext(Msg.getMsg(Env.getCtx(), "FileImportFileInfo"));
bFile.setUpload("true");
bFile.setUpload(AdempiereWebUI.getUploadSetting());
bFile.addEventListener(Events.ON_UPLOAD, this);
hb.appendChild(bFile);
vb.appendChild(hb);

View File

@ -28,6 +28,7 @@ import java.util.logging.Level;
import javax.activation.DataSource;
import org.adempiere.webui.AdempiereWebUI;
import org.adempiere.webui.component.AttachmentItem;
import org.adempiere.webui.component.Button;
import org.adempiere.webui.component.Column;
@ -313,7 +314,7 @@ public class WEMailDialog extends Window implements EventListener<Event>, ValueC
Button btn = new Button();
btn.setImage(ThemeManager.getThemeResource("images/Attachment24.png"));
btn.setUpload("true");
btn.setUpload(AdempiereWebUI.getUploadSetting());
btn.addEventListener(Events.ON_UPLOAD, this);
btn.setTooltiptext(Msg.getMsg(Env.getCtx(), "Attachment"));
confirmPanel.addComponentsLeft(btn);

View File

@ -21,6 +21,7 @@ import java.sql.Clob;
import java.sql.SQLException;
import java.util.logging.Level;
import org.adempiere.webui.AdempiereWebUI;
import org.adempiere.webui.component.Button;
import org.adempiere.webui.component.Panel;
import org.adempiere.webui.component.Window;
@ -151,7 +152,7 @@ public class WMediaDialog extends Window implements EventListener<Event>
bLoad.setImage(ThemeManager.getThemeResource("images/Import24.png"));
bLoad.setTooltiptext(Msg.getMsg(Env.getCtx(), "Load"));
bLoad.addEventListener(Events.ON_UPLOAD, this);
bLoad.setUpload("true");
bLoad.setUpload(AdempiereWebUI.getUploadSetting());
bDelete.setImage(ThemeManager.getThemeResource("images/Delete24.png"));
bDelete.setTooltiptext(Msg.getMsg(Env.getCtx(), "Delete"));