我正在尝试使用requests-aws包,如下所示:
In [1]: import requests
In [2]: from awsauth import S3Auth
然后,在定义ACCESS_KEY
和SECRET_KEY
变量以及url
之后,其中'http://mybuck.s3.amazonaws.com/file.txt'
具有指定格式mybuck
(PUT
替换为实际()),我尝试发出In [8]: r = requests.put(url, data=s, auth=S3Auth(ACCESS_KEY
...: , SECRET_KEY))
In [9]: r.ok
Out[9]: False
In [10]: r.reason
Out[10]: 'Bad Request'
请求:
ChatHelper.getInstance().login(user, new QBEntityCallback<Void>() {
@Override
public void onSuccess(Void result, Bundle bundle) {
if(progressDialog!=null)
progressDialog.dismiss();
loginToChat();
android.util.Log.e(TAG, "QB Chat Login successfully");
}
@Override
public void onError(QBResponseException e) {
android.util.Log.e(TAG, "Error Login in Home Screen>>>" +e);
if(progressDialog!=null)
progressDialog.dismiss();
}
});
private void loginToChat() {
if(SharedPrefsHelper.getInstance().getQbUser()!=null){
final QBUser user = SharedPrefsHelper.getInstance().getQbUser();
ChatHelper.getInstance().loginToChat(user, new QBEntityCallback<Void>() {
@Override
public void onSuccess(Void result, Bundle bundle) {
android.util.Log.v(TAG, "Chat login onSuccess()");
}
@Override
public void onError(QBResponseException e) {
android.util.Log.w(TAG, "Chat login onError(): " + e);
}
});
}
}
然而,正如您所看到的,它被视为“错误请求”(状态代码400)。这里出了什么问题?