|
本帖最后由 developerML 于 2017-9-22 11:01 编辑
请教下面报错应如何解决
package x5;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import javax.naming.NamingException;
import sun.misc.BASE64Decoder;
访问限制:由于对必需的库 D:\WeX5_V3.5\java\jre1.8\lib\rt.jar 具有一定限制,因此无法访问类型 BASE64Decoder Uploadphoto.java /BaasServer/baas/x5 第 9 行 Java 问题
import com.alibaba.fastjson.JSONObject;
import com.justep.baas.action.ActionContext;
import com.justep.baas.data.sql.SQLException;
public class Uploadphoto {
public static JSONObject uploadPicfile(JSONObject params, ActionContext context) throws SQLException, NamingException, IOException {
System.out.println("uploadPicfile is running...");
String ownerID = params.getString("ownerID");
String storeFileName = params.getString("storeFileName");
String picData = params.getString("picData");
String baasPath = Thread.currentThread().getContextClassLoader().getResource("").getPath() ;
String docStorePath = baasPath + File.separator + "x5" +File.separator + "uploadfiles" ;
File docstoreDir = new File(docStorePath);
if(!(docstoreDir.exists() && docstoreDir.isDirectory())){
docstoreDir.mkdirs();
}
String storePath = docStorePath + File.separator + ownerID;
File storeDir = new File(storePath);
if(!(storeDir.exists() && storeDir.isDirectory())){
storeDir.mkdirs();
}
System.out.println("后台计算的baasPath的值:"+ baasPath);
System.out.println("后台计算的docStorePath的值:"+ docStorePath);
System.out.println("后台计算的storeDir的值:"+ storeDir);
BASE64Decoder decoder = new BASE64Decoder();
try {
byte[] decodedBytes = decoder.decodeBuffer(picData);
String imgFile = storePath + File.separator + storeFileName;
FileOutputStream out = new FileOutputStream(imgFile);
out.write(decodedBytes);
out.close();
System.out.println("图片上传成功!");
} catch (Exception e) {
System.out.println("图片上传失败!");
e.printStackTrace();
}
return null;
}
}
|
-
|