Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

on iOS, store only relative portion of directory path #277

Closed
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.graphics.BitmapFactory;
import android.os.Build;

import androidx.annotation.NonNull;
import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationManagerCompat;
import androidx.core.content.ContextCompat;

import android.os.Environment;
import android.os.Handler;
import android.provider.MediaStore;
import android.text.TextUtils;
import android.util.Log;

import androidx.annotation.NonNull;
import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationManagerCompat;
import androidx.core.content.ContextCompat;
import androidx.work.Worker;
import androidx.work.WorkerParameters;

import org.json.JSONException;
import org.json.JSONObject;

Expand All @@ -45,9 +45,6 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import androidx.work.Worker;
import androidx.work.WorkerParameters;

import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.common.PluginRegistry;
Expand Down Expand Up @@ -196,7 +193,7 @@ public Result doWork() {
File partialFile = new File(saveFilePath);
if (partialFile.exists()) {
isResume = true;
log("exists file for "+ filename + "automatic resuming...");
log("exists file for " + filename + "automatic resuming...");
}

try {
Expand Down Expand Up @@ -308,7 +305,7 @@ private void downloadFile(Context context, String fileURL, String savedDir, Stri

if ((responseCode == HttpURLConnection.HTTP_OK || (isResume && responseCode == HttpURLConnection.HTTP_PARTIAL)) && !isStopped()) {
String contentType = httpConn.getContentType();
long contentLength = httpConn.getContentLengthLong();
long contentLength = Build.VERSION.SDK_INT >= 24 ? httpConn.getContentLengthLong() : (long) httpConn.getContentLength();
log("Content-Type = " + contentType);
log("Content-Length = " + contentLength);

Expand Down
2 changes: 1 addition & 1 deletion ios/Classes/FlutterDownloaderPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ - (BOOL)openDocumentWithURL:(NSURL*)url {

- (NSURL*)fileUrlFromDict:(NSDictionary*)dict
{
NSString *savedDir = dict[KEY_SAVED_DIR];
NSString *savedDir = [self absoluteSavedDirPath:dict[KEY_SAVED_DIR]];
NSString *filename = dict[KEY_FILE_NAME];
if (debug) {
NSLog(@"savedDir: %@", savedDir);
Expand Down
1 change: 0 additions & 1 deletion lib/src/downloader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ class FlutterDownloader {
bool openFileFromNotification = true,
bool requiresStorageNotLow = true}) async {
assert(_initialized, 'FlutterDownloader.initialize() must be called first');
assert(Directory(savedDir).existsSync());

StringBuffer headerBuilder = StringBuffer();
if (headers != null) {
Expand Down