起步软件技术论坛
搜索
 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1951|回复: 2

[结贴] 图片上传baas后端代码报错求助

[复制链接]

31

主题

116

帖子

259

积分

中级会员

Rank: 3Rank: 3

积分
259
QQ
发表于 2017-9-22 10:37:02 | 显示全部楼层 |阅读模式
本帖最后由 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;
}
        
        

        
        
        
        
}

未标题-1 拷贝.jpg

91

主题

13万

帖子

3万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
35913
发表于 2017-9-22 17:44:16 | 显示全部楼层
到网上查找看看需要jdk什么版本的?
远程的联系方法QQ1392416607,添加好友时,需在备注里注明其论坛名字及ID,公司等信息
发远程时同时也发一下帖子地址,方便了解要解决的问题  WeX5教程  WeX5下载



如按照该方法解决,请及时跟帖,便于版主结贴
回复 支持 反对

使用道具 举报

31

主题

116

帖子

259

积分

中级会员

Rank: 3Rank: 3

积分
259
QQ
 楼主| 发表于 2017-9-23 15:07:17 | 显示全部楼层
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|X3技术论坛|Justep Inc.    

GMT+8, 2024-4-20 05:57 , Processed in 0.061674 second(s), 26 queries .

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表