use of com.amazonaws.services.s3.Headers in project EhViewer by seven332.
the class EhEngine method signIn.
public static String signIn(@Nullable EhClient.Task task, OkHttpClient okHttpClient, String username, String password, String recaptchaChallenge, String recaptchaResponse) throws Exception {
FormBody.Builder builder = new FormBody.Builder().add("UserName", username).add("PassWord", password).add("submit", "Log me in").add("CookieDate", "1").add("temporary_https", "off");
if (!TextUtils.isEmpty(recaptchaChallenge) && !TextUtils.isEmpty(recaptchaResponse)) {
builder.add("recaptcha_challenge_field", recaptchaChallenge);
builder.add("recaptcha_response_field", recaptchaResponse);
}
String url = EhUrl.API_SIGN_IN;
Log.d(TAG, url);
Request request = new EhRequestBuilder(url, null != task ? task.getEhConfig() : Settings.getEhConfig()).post(builder.build()).build();
Call call = okHttpClient.newCall(request);
// Put call
if (null != task) {
task.setCall(call);
}
String body = null;
Headers headers = null;
int code = -1;
try {
Response response = call.execute();
code = response.code();
headers = response.headers();
body = response.body().string();
return SignInParser.parse(body);
} catch (Exception e) {
throwException(call, code, headers, body, e);
throw e;
}
}
use of com.amazonaws.services.s3.Headers in project EhViewer by seven332.
the class EhEngine method getProfileInternal.
private static ProfileParser.Result getProfileInternal(@Nullable EhClient.Task task, OkHttpClient okHttpClient, String url) throws Exception {
Log.d(TAG, url);
Request request = new EhRequestBuilder(url, null != task ? task.getEhConfig() : Settings.getEhConfig()).build();
Call call = okHttpClient.newCall(request);
// Put call
if (null != task) {
task.setCall(call);
}
String body = null;
Headers headers = null;
int code = -1;
try {
Response response = call.execute();
code = response.code();
headers = response.headers();
body = response.body().string();
return ProfileParser.parse(body);
} catch (Exception e) {
throwException(call, code, headers, body, e);
throw e;
}
}
use of com.amazonaws.services.s3.Headers in project EhViewer by seven332.
the class EhEngine method modifyFavorites.
public static FavoritesParser.Result modifyFavorites(@Nullable EhClient.Task task, OkHttpClient okHttpClient, String url, long[] gidArray, int dstCat, boolean callApi) throws Exception {
String catStr;
if (dstCat == -1) {
catStr = "delete";
} else if (dstCat >= 0 && dstCat <= 9) {
catStr = "fav" + dstCat;
} else {
throw new EhException("Invalid dstCat: " + dstCat);
}
FormBody.Builder builder = new FormBody.Builder();
builder.add("ddact", catStr);
for (long gid : gidArray) {
builder.add("modifygids[]", Long.toString(gid));
}
builder.add("apply", "Apply");
Log.d(TAG, url);
Request request = new EhRequestBuilder(url, null != task ? task.getEhConfig() : Settings.getEhConfig()).post(builder.build()).build();
Call call = okHttpClient.newCall(request);
// Put call
if (null != task) {
task.setCall(call);
}
String body = null;
Headers headers = null;
FavoritesParser.Result result;
int code = -1;
try {
Response response = call.execute();
code = response.code();
headers = response.headers();
body = response.body().string();
result = FavoritesParser.parse(body);
} catch (Exception e) {
throwException(call, code, headers, body, e);
throw e;
}
if (callApi && result.galleryInfoList.size() > 0) {
fillGalleryListByApi(task, okHttpClient, result.galleryInfoList);
}
for (GalleryInfo info : result.galleryInfoList) {
info.thumb = EhUrl.getFixedPreviewThumbUrl(info.thumb);
}
return result;
}
use of com.amazonaws.services.s3.Headers in project EhViewer by seven332.
the class EhEngine method getArchiveList.
public static Pair<String, Pair<String, String>[]> getArchiveList(@Nullable EhClient.Task task, OkHttpClient okHttpClient, String url) throws Exception {
Log.d(TAG, url);
Request request = new EhRequestBuilder(url, null != task ? task.getEhConfig() : Settings.getEhConfig()).build();
Call call = okHttpClient.newCall(request);
// Put call
if (null != task) {
task.setCall(call);
}
String body = null;
Headers headers = null;
Pair<String, Pair<String, String>[]> result;
int code = -1;
try {
Response response = call.execute();
code = response.code();
headers = response.headers();
body = response.body().string();
result = ArchiveParser.parse(body);
} catch (Exception e) {
throwException(call, code, headers, body, e);
throw e;
}
return result;
}
use of com.amazonaws.services.s3.Headers in project instructure-android by instructure.
the class FileFolderAPI method uploadFileSynchronousNoRedirect.
@WorkerThread
public static /* Used to manually handle the last redirect */
RemoteFile uploadFileSynchronousNoRedirect(@NonNull RestBuilder adapter, String uploadUrl, Map<String, RequestBody> uploadParams, String mimeType, File file) throws IOException {
RestParams params = new RestParams.Builder().withShouldIgnoreToken(true).withDomain(uploadUrl).withPerPageQueryParam(false).build();
RequestBody fileBody = RequestBody.create(MediaType.parse(mimeType), file);
Headers headers = adapter.buildNoRedirects(FilesFoldersInterface.class, params).uploadFile(uploadParams, fileBody).execute().headers();
String redirect = headers.get("Location");
String newFileUrl = redirect.split("/create_success")[0];
// POST to the redirect... according to the docs we need to do this to finalize the file upload process
RemoteFile newFile = adapter.build(FilesFoldersInterface.class, params).postNewlyCreatedFile(redirect).execute().body();
// We weren't receiving a url in the response from the POST to the redirect - here we grab the full file info as a work around
FileFolder fileFolder = FileFolderManager.getFileFolderFromURLSynchronous(newFileUrl);
newFile.setUrl(fileFolder.getUrl());
newFile.setThumbnailUrl(fileFolder.getThumbnailUrl());
return newFile;
}
Aggregations