forked from github/szkolny
[API] Implement Idziennik homework attachment downloading. Change attachment events to sticky.
This commit is contained in:
@ -19,7 +19,7 @@ import okhttp3.internal.Util;
|
||||
* <p>Time : 下午2:39.</p>
|
||||
*/
|
||||
public class FileCallbackHandler extends AbsCallbackHandler<File> {
|
||||
final private File file;
|
||||
private File file;
|
||||
final private static int BUFFER_SIZE = 4096;
|
||||
|
||||
public FileCallbackHandler(Context context){
|
||||
@ -66,6 +66,14 @@ public class FileCallbackHandler extends AbsCallbackHandler<File> {
|
||||
if (file == null){
|
||||
throw new IllegalArgumentException("File == null");
|
||||
}
|
||||
if (this.file.isDirectory()) {
|
||||
String contentDisposition = response.header("content-disposition");
|
||||
if (contentDisposition != null) {
|
||||
String filename = contentDisposition.substring(contentDisposition.indexOf("\"")+1, contentDisposition.lastIndexOf("\""));
|
||||
this.file = new File(file, filename);
|
||||
file = this.file;
|
||||
}
|
||||
}
|
||||
InputStream instream = response.body().byteStream();
|
||||
long contentLength = response.body().contentLength();
|
||||
FileOutputStream buffer = new FileOutputStream(file);
|
||||
|
Reference in New Issue
Block a user