Comments (8)
This could be because you have .
(dot) as part of the bucket name. One of the advices is to use '-' instead of '.' in S3 bucket names that will be accessed via HTTPS.
from aws-sdk-android.
For refrence this my code snippet
Picasso.Builder builder = new Picasso.Builder(this);
Picasso picasso = builder.downloader(new OkHttpDownloader(this) {
@Override
protected HttpURLConnection openConnection(Uri uri) throws IOException {
// get bucket name and filename (key) from uri (https://s3.amazonaws.com/BUCKET_NAME/FILENAME.JPG)
String BUCKET_NAME;
URL url = sS3Client.generatePresignedUrl("<BUCKET_NAME>", "<FILENAME>", nowPlus10Minutes.getTime());
HttpURLConnection connection =null;
try {
connection = super.openConnection(Uri.parse(url.toString()));
Log.v(" === connection.getURL()", connection.getURL().toString());
}
catch (Exception e){
Log.v( "Exception occured ", "picasso openConnection");
}
return connection;
}
}).build();
picasso.setLoggingEnabled(true);
picasso.load("https://s3.amazonaws.com/BUCKET_NAME/FILENAME.JPG").into(imageView,new Callback() {
@Override
public void onSuccess() {
Log.v("-------","success");
}
@Override
public void onError() {
Log.v("--------","error");
}
});
Appriciate any help,
Thanks
from aws-sdk-android.
I'm sorry your having trouble rahulgautam. Unfortunately I cannot seem to reproduce the issue. I've tried generating a pre-signed URL and the image opens fine in Firefox/Chrome/Safari as well as on the emulator browser and I am also able to download it fine. The code I used to test is below. Let me know if you can't get this to work for you.
class testPresignedURL extends AsyncTask<Void,Void,Void>{
@Override
protected Void doInBackground(Void... params) {
Calendar tomorrow = Calendar.getInstance();
tomorrow.add(Calendar.HOUR, 24);
Date td = tomorrow.getTime();
URL url = s3Client.generatePresignedUrl(YOUR_BUCKET, YOUR_IMAGE, td);
Log.d(TAG,"URL is: "+url.toString());
//Uncomment code below to see in phone's browser
// Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url.toString()));
// startActivity(browserIntent);
File storagePath = new File(Environment
.getExternalStorageDirectory()
+ "/testpresignedurl/images/");
storagePath.mkdirs();
File file = new File(storagePath, YOUR_FILE);
HttpURLConnection urlConnection;
try {
urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setRequestMethod("GET");
urlConnection.connect();
FileOutputStream fileOutput = new FileOutputStream(file);
InputStream inputStream = urlConnection.getInputStream();
int downloadedSize = 0;
byte[] buffer = new byte[1024];
int bufferLength = 0;
while ((bufferLength = inputStream.read(buffer)) > 0) {
fileOutput.write(buffer, 0, bufferLength);
downloadedSize += bufferLength;
Log.d(TAG,"downloaded chunk total: "+downloadedSize);
}
fileOutput.close();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
}
Weston
from aws-sdk-android.
Hi @wdane,
Thanks for reply and code-snippet,
When I open the URL generated by presignedURL, same thing happened.
Although image gets download through asynctask (code snippet you provide).
Now a days there is new issue with SSL (poodle etc), is something related to this, because I still have not figure out what causing this behaviour.
from aws-sdk-android.
Can you show is what the actual URL is? Also what is your development environment like? If you are using a packet sniffer that could cause issues.
Have you tried accessing the URL from a different device? Maybe on a different network? That might help narrow down the source of the issue
from aws-sdk-android.
Yes I do have .
(dot) as part of bucket name, I could not share the exact URL but this is how it looks
https://my.bucket.name.s3.amazonaws.com/0076bb56-32qc-11d4-90da-0ac2f0fa92c6_1410249846.047449.JPG?AWSAccessKeyId=ACCESS93NPP3OW4IQWER&Expires=1414587123&Signature=byIJwcjtcZ9bW%2F2O8i%2FdsprvsOM%3D
I am not using any packet sniffer, development enviourment is Mac OS X Yosemite and private optical network infrastructure.
from aws-sdk-android.
Hi @SoMCUSDev Thanks for your help man, removing .
from my bucket name worked for me.
AWS Console should mention this information when a user creates a bucket. that would save all this trouble to users.
Thanks guys for all your help
from aws-sdk-android.
Thanks Rahulgautam, let us know if you have any further issues!
from aws-sdk-android.
Related Issues (20)
- Non-fatal Exception: com.amazonaws.AmazonClientException: Unable to execute HTTP request: timeout HOT 4
- Response timeout issues in the AWS SDK for Android HOT 20
- [Question&Help] Why receive DefaultDataset: Synchronize failed because it exceeded the maximum retries HOT 5
- Analytics SDK - Android - InitializationException in amazonmobileanalytics. Encountered an error accessing the file system HOT 2
- How to upload to s3 with endpoint URL HOT 2
- Android 14: Cognito Hosted UI auth redirect response fails to reopen app after successful login. HOT 11
- TransferNetworkConnectionType.MOBILE doesn't work when WiFi is connected on "no internet" network (API 25) HOT 1
- Resend MFA Code HOT 2
- Kinesis Video sending a video from External source HOT 4
- S3 UploadTask fails with some files HOT 5
- You must be signed-in with Cognito Userpools to be able to use getTokens HOT 8
- Consumer proguard rules are too broad HOT 1
- My Device cannot get get/accepted or update/accepted, but same account in other devices is OK. HOT 1
- Pinpoint Analytics causes crash - SQLiteReadOnlyDatabaseException: attempt to write a readonly database HOT 7
- Should I expose Identity pool ID in my android app's source code? HOT 3
- Session issue : No cached session HOT 10
- Crash: java.lang.SecurityException Package android does not belong to 10347 HOT 3
- aws-translate - Need TranslateText function text field accept array HOT 1
- TransferWorkerObserver$attachObserverForPendingTransfer$1.invokeSuspend (API 25)
- Play mp4 file using aws kinesis HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aws-sdk-android.