我正在定制亚马逊的S3 Uploader示例程序以满足我的需求。创建存储桶后,我会向其上传视频。
PutObjectRequest por = new PutObjectRequest(buckets.get(0).getName(), Constants.VIDEO_NAME, new java.io.File(filePath));
当我运行上面的行时,我回到下面的例外:
Unable to calculate MD5 has: /storage/....../bla.mp4: open failed: EACCES (Permission Denied)
堆栈追踪:
12-04 14:39:21.981 29372-29441/com.amazonaws.demo.s3uploader E/ERR﹕ com.amazonaws.AmazonClientException: Unable to calculate MD5 hash: /storage/emulated/0/DCIM/Camera/VID_20131203_180120.mp4: open failed: EACCES (Permission denied)
at com.amazonaws.services.s3.AmazonS3Client.putObject(AmazonS3Client.java:1139)
at com.amazonaws.demo.s3uploader.S3UploaderActivity$S3PutObjectTask.doInBackground(S3UploaderActivity.java:160)
at com.amazonaws.demo.s3uploader.S3UploaderActivity$S3PutObjectTask.doInBackground(S3UploaderActivity.java:120)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
Caused by: java.io.FileNotFoundException: /storage/emulated/0/DCIM/Camera/VID_20131203_180120.mp4: open failed: EACCES (Permission denied)
at libcore.io.IoBridge.open(IoBridge.java:409)
at java.io.FileInputStream.<init>(FileInputStream.java:78)
at com.amazonaws.services.s3.AmazonS3Client.putObject(AmazonS3Client.java:1135)
at com.amazonaws.demo.s3uploader.S3UploaderActivity$S3PutObjectTask.doInBackground(S3UploaderActivity.java:160)
at com.amazonaws.demo.s3uploader.S3UploaderActivity$S3PutObjectTask.doInBackground(S3UploaderActivity.java:120)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
Caused by: libcore.io.ErrnoException: open failed: EACCES (Permission denied)
at libcore.io.Posix.open(Native Method)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
at libcore.io.IoBridge.open(IoBridge.java:393)
at java.io.FileInputStream.<init>(FileInputStream.java:78)
at com.amazonaws.services.s3.AmazonS3Client.putObject(AmazonS3Client.java:1135)
at com.amazonaws.demo.s3uploader.S3UploaderActivity$S3PutObjectTask.doInBackground(S3UploaderActivity.java:160)
at com.amazonaws.demo.s3uploader.S3UploaderActivity$S3PutObjectTask.doInBackground(S3UploaderActivity.java:120)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
OS = 4.4 / KitKat,Device = Nexus 4
发生了什么事?
答案 0 :(得分:4)
不要像我一样。在尝试上传到S3之前检查文件是否存在。
答案 1 :(得分:3)