开发者社区> 问答> 正文

内网无法上传对象

public class OssTest {
     public static void main(String[] args){
         try{
            String accessKeyId = "";
            String accessKeySecret = "";
            String endpoint = "https://oss-cn-shanghai-internal.aliyuncs.com";
          
            OSSClient client = new OSSClient(endpoint, accessKeyId, accessKeySecret);
            System. out.println( "client is build!");
             // [font='宋体']上传文件流
[font='宋体']        
            // [font='宋体']上传字符串
[font='宋体']            String content = "Hello OSS";
            client.putObject( "ecg-zxyl", "12312313", new ByteArrayInputStream(content.getBytes()));
             // [font='宋体']关闭 client
            client.shutdown();

        } catch(Exception ex){
            ex.printStackTrace();
        }
    }
}
按照文档编写的例子,ecs服务器和oss都在华东2,同一个区域!如果endpoint修改为外网访问的地址就没有问题。如果为目前的内网地址的话,到了pubObject这一步就出错了异常如下: om.aliyun.oss.ClientException: ConnectionTimeoutat com.aliyun.oss.common.utils.ExceptionFactory.createNetworkException(ExceptionFactory.java:71)at com.aliyun.oss.common.comm.DefaultServiceClient.sendRequestCore(DefaultServiceClient.java:128)at com.aliyun.oss.common.comm.ServiceClient.sendRequestImpl(ServiceClient.java:123)at com.aliyun.oss.common.comm.ServiceClient.sendRequest(ServiceClient.java:68)at com.aliyun.oss.internal.OSSOperation.send(OSSOperation.java:94)at com.aliyun.oss.internal.OSSOperation.doOperation(OSSOperation.java:149)at com.aliyun.oss.internal.OSSOperation.doOperation(OSSOperation.java:113)at com.aliyun.oss.internal.OSSObjectOperation.writeObjectInternal(OSSObjectOperation.java:790)at com.aliyun.oss.internal.OSSObjectOperation.putObject(OSSObjectOperation.java:145)at com.aliyun.oss.OSSClient.putObject(OSSClient.java:558)at com.aliyun.oss.OSSClient.putObject(OSSClient.java:540)at com.aliyun.oss.OSSClient.putObject(OSSClient.java:534)at OssTest.main(OssTest.java:34)

展开
收起
williamwang2017 2017-03-31 08:42:01 2813 0
2 条回答
写回答
取消 提交回答
  • Re内网无法上传对象
    是内网地址搞错了,因为网络类型不通
    2017-04-06 11:04:03
    赞同 展开评论 打赏
  • 换个节点呢?

    -------------------------

    你的意思是说,现在可以了?

    2017-03-31 14:04:28
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载