打开图库应用
$params = array(
'AWSAccessKeyId' => "AKIAJB4PTEUXXXXXX",
'Action' => "GetReportRequestList",
'SellerId' => "A4XLZXXXXXX",
'SignatureMethod' => "HmacSHA256",
'SignatureVersion' => "2",
'Timestamp' => gmdate("Y-m-d\TH:i:s.\\0\\0\\0\\Z", time()),
'Version' => "2009-01-01",
'MarketplaceId' => "ATVPDKIKX0DER",
);
// Sort the URL parameters
$url_parts = array();
foreach (array_keys($params) as $key)
$url_parts[] = $key . "=" . str_replace('%7E', '~', rawurlencode($params[$key]));
sort($url_parts);
// Construct the string to sign
$url_string = implode("&", $url_parts);
$string_to_sign = "GET\nmws.amazonservices.com\n/\n" . $url_string;
// Sign the request
$signature = hash_hmac("sha256", $string_to_sign, "7D/QEUYXrJ/XQYyAAMPgiwTXXXXXX", TRUE);
// Base64 encode the signature and make it URL safe
$signature = urlencode(base64_encode($signature));
$url = "https://mws.amazonservices.com/" . '?' . $url_string . "&Signature=" . $signature;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
$response = curl_exec($ch);
$parsed_xml = simplexml_load_string($response);
选择Goes to OnActivityResult
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
dialog1.dismiss();
startActivityForResult(Intent.createChooser(intent,"Select Picture"), SELECT_PICTURE);
使用AndroidMultiPartEntity启动Asynctask将图像上传到服务器
selectedImageUri = data.getData();
selectedImagePath = getPath(selectedImageUri);
if(selectedImagePath==null)
{
Toast.makeText(MyProfileNewActivity.this, "Wrong File Please Select From Gallery", Toast.LENGTH_SHORT).show();
}
else
{
UploadProfilePicGallery uppg=new UploadProfilePicGallery();
uppg.execute();
}**
注意错误仅在用户选择摄像机拍摄的图像时出现...除此之外,下载的图像可以从图库上传。 (有时崩溃有时OutOfMemoryErrorOccurs)
请给我一个解决方案我工作了3天以上我无法找到问题........ 如果您有任何其他正常工作的代码请与我分享....
答案 0 :(得分:1)
使用Multipart上传图片。 Click here以获取完整示例。
答案 1 :(得分:0)
只需通过更改您的Intent.May帮助
来尝试此操作 Intent intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE);