小编Pab*_*blo的帖子

AWS Java S3上传错误:"配置文件不能为空"

尝试从Java Spring应用程序上传文件到Amazon S3时出现异常.方法很简单:

private void productionFileSaver(String keyName, File f) throws InterruptedException {

        String bucketName = "{my-bucket-name}";
        TransferManager tm = new TransferManager(new ProfileCredentialsProvider());        
        // TransferManager processes all transfers asynchronously, 
        // so this call will return immediately.
        Upload upload = tm.upload(
                bucketName, keyName, new File("/mypath/myfile.png"));

        try {
            // Or you can block and wait for the upload to finish
            upload.waitForCompletion();
            System.out.println("Upload complete.");
        } catch (AmazonClientException amazonClientException) {
            System.out.println("Unable to upload file, upload was aborted.");
            amazonClientException.printStackTrace();
        }
    }
Run Code Online (Sandbox Code Playgroud)

这与amazon 在此处提供的基本相同,并且在尝试此其他版本时会出现完全相同的消息("配置文件不能为空")的相同异常.该问题与文件不存在或为空无关(我已经检查过一千种 …

java amazon amazon-s3

15
推荐指数
2
解决办法
1万
查看次数

标签 统计

amazon ×1

amazon-s3 ×1

java ×1