mirror of
https://github.com/ReaJason/MemShellParty.git
synced 2026-09-22 07:00:43 +08:00
Dev Deploy / Build Jar (push) Has been cancelled
Dev Deploy / Docker Push (push) Has been cancelled
Dev Deploy / Deploy to Maven Central (push) Has been cancelled
Dev Deploy / Deploy to Northflank (push) Has been cancelled
MemShell IntegrationTest / xxljob (push) Has been cancelled
MemShell IntegrationTest / springwebmvc (push) Has been cancelled
MemShell IntegrationTest / springwebflux (push) Has been cancelled
MemShell IntegrationTest / struct2 (push) Has been cancelled
MemShell IntegrationTest / tomcat (push) Has been cancelled
MemShell IntegrationTest / glassfish (push) Has been cancelled
MemShell IntegrationTest / jbosseap (push) Has been cancelled
MemShell IntegrationTest / jetty (push) Has been cancelled
MemShell IntegrationTest / payara (push) Has been cancelled
MemShell IntegrationTest / wildfly (push) Has been cancelled
MemShell IntegrationTest / jbossas (push) Has been cancelled
MemShell IntegrationTest / resin (push) Has been cancelled
MemShell IntegrationTest / weblogic (push) Has been cancelled
MemShell IntegrationTest / websphere7 (push) Has been cancelled
MemShell IntegrationTest / websphere (push) Has been cancelled
Probe IntegrationTest / springwebmvc (push) Has been cancelled
Probe IntegrationTest / struct2 (push) Has been cancelled
Probe IntegrationTest / tomcat (push) Has been cancelled
Probe IntegrationTest / glassfish (push) Has been cancelled
Probe IntegrationTest / jbosseap (push) Has been cancelled
Probe IntegrationTest / jetty (push) Has been cancelled
Probe IntegrationTest / payara (push) Has been cancelled
Probe IntegrationTest / wildfly (push) Has been cancelled
Probe IntegrationTest / jbossas (push) Has been cancelled
Probe IntegrationTest / resin (push) Has been cancelled
Probe IntegrationTest / weblogic (push) Has been cancelled
Probe IntegrationTest / websphere7 (push) Has been cancelled
Probe IntegrationTest / websphere (push) Has been cancelled
Unit-Test / UniteTest (push) Has been cancelled
63 lines
1.8 KiB
Java
63 lines
1.8 KiB
Java
import com.opensymphony.xwork2.ActionSupport;
|
|
import org.apache.commons.io.FileUtils;
|
|
import org.apache.struts2.ServletActionContext;
|
|
|
|
import java.io.File;
|
|
|
|
/**
|
|
* @author ReaJason
|
|
* @since 2024/11/26
|
|
*/
|
|
public class UploadAction extends ActionSupport {
|
|
|
|
private File upload;
|
|
private String uploadFileName;
|
|
private String uploadContentType;
|
|
|
|
private static final String UPLOAD_DIRECTORY = "/";
|
|
|
|
@Override
|
|
public String execute() throws Exception {
|
|
try {
|
|
if (upload != null) {
|
|
String uploadFolder = ServletActionContext.getServletContext().getRealPath(UPLOAD_DIRECTORY);
|
|
if (!uploadFolder.endsWith(File.separator)) {
|
|
uploadFolder += File.separator;
|
|
}
|
|
String uploadPath = uploadFolder + uploadFileName;
|
|
File destFile = new File(uploadPath);
|
|
FileUtils.copyFile(upload, destFile);
|
|
ServletActionContext.getResponse().getWriter().println("file upload success: " + uploadPath);
|
|
}
|
|
return SUCCESS;
|
|
} catch (Exception e) {
|
|
ServletActionContext.getResponse().getWriter().println("file upload failed: " + e.getMessage());
|
|
return ERROR;
|
|
}
|
|
}
|
|
|
|
public File getUpload() {
|
|
return upload;
|
|
}
|
|
|
|
public void setUpload(File upload) {
|
|
this.upload = upload;
|
|
}
|
|
|
|
public String getUploadFileName() {
|
|
return uploadFileName;
|
|
}
|
|
|
|
public void setUploadFileName(String uploadFileName) {
|
|
this.uploadFileName = uploadFileName;
|
|
}
|
|
|
|
public String getUploadContentType() {
|
|
return uploadContentType;
|
|
}
|
|
|
|
public void setUploadContentType(String uploadContentType) {
|
|
this.uploadContentType = uploadContentType;
|
|
}
|
|
}
|