package net.gotev.uploadservice;

import android.content.Context;
import android.content.Intent;
import java.io.FileNotFoundException;
import java.net.MalformedURLException;
/* loaded from: classes.dex */
public class MultipartUploadRequest extends HttpUploadRequest<MultipartUploadRequest> {
    private static final String LOG_TAG = "MultipartUploadRequest";
    private boolean isUtf8Charset;

    public MultipartUploadRequest(Context context, String str, String str2) throws IllegalArgumentException, MalformedURLException {
        super(context, str, str2);
        this.isUtf8Charset = false;
    }

    public MultipartUploadRequest(Context context, String str) throws MalformedURLException, IllegalArgumentException {
        this(context, null, str);
    }

    /* JADX INFO: Access modifiers changed from: protected */
    @Override // net.gotev.uploadservice.HttpUploadRequest, net.gotev.uploadservice.UploadRequest
    public void initializeIntent(Intent intent) {
        super.initializeIntent(intent);
        intent.putExtra("multipartUtf8Charset", this.isUtf8Charset);
    }

    @Override // net.gotev.uploadservice.UploadRequest
    protected Class<? extends UploadTask> getTaskClass() {
        return MultipartUploadTask.class;
    }

    public MultipartUploadRequest addFileToUpload(String str, String str2, String str3, String str4) throws FileNotFoundException, IllegalArgumentException {
        UploadFile uploadFile = new UploadFile(str);
        String path = uploadFile.getPath();
        if (str2 == null || BuildConfig.FLAVOR.equals(str2)) {
            throw new IllegalArgumentException("Please specify parameterName value for file: " + path);
        }
        uploadFile.setProperty("httpParamName", str2);
        if (str4 == null || str4.isEmpty()) {
            str4 = uploadFile.getContentType(this.context);
            String str5 = LOG_TAG;
            Logger.debug(str5, "Auto-detected MIME type for " + path + " is: " + str4);
        } else {
            String str6 = LOG_TAG;
            Logger.debug(str6, "Content Type set for " + path + " is: " + str4);
        }
        uploadFile.setProperty("httpContentType", str4);
        if (str3 == null || BuildConfig.FLAVOR.equals(str3)) {
            str3 = uploadFile.getName(this.context);
            String str7 = LOG_TAG;
            Logger.debug(str7, "Using original file name: " + str3);
        } else {
            String str8 = LOG_TAG;
            Logger.debug(str8, "Using custom file name: " + str3);
        }
        uploadFile.setProperty("httpRemoteFileName", str3);
        this.params.addFile(uploadFile);
        return this;
    }

    public MultipartUploadRequest addFileToUpload(String str, String str2, String str3) throws FileNotFoundException, IllegalArgumentException {
        return addFileToUpload(str, str2, str3, null);
    }

    public MultipartUploadRequest addFileToUpload(String str, String str2) throws FileNotFoundException, IllegalArgumentException {
        return addFileToUpload(str, str2, null, null);
    }

    public MultipartUploadRequest setUtf8Charset() {
        this.isUtf8Charset = true;
        return this;
    }
}
