Skip to content Skip to sidebar Skip to footer

Uploading Multiple Image To Aws Server Using Rxjava

I am trying to upload multiple image to ASW using rxJava. I have found a kotlin example. Upload multiple images(nearly 100) from Android to Amazon S3?. I tried to implement it usin

Solution 1:

I've already reply to similar questions for running multiple requests in parallel. you can find them here

I can suggest you this implementation :

publicfinalclassRecordData {
    privatefinal String url;
    privatefinal String fileType;
    privatefinal String fileName;

    publicRecordData(String url, String fileType, String fileName) {
        this.url = url;
        this.fileType = fileType;
        this.fileName = fileName;
    }

    public String getUrl() {
        return url;
    }

    public String getFileType() {
        return fileType;
    }

    public String getFileName() {
        return fileName;
    }
}

public RecordData toRecord(File file) {
    StringfileExtension= MimeTypeMap.getFileExtensionFromUrl(file.toString());
    StringfileName= Calendar.getInstance().getTimeInMillis() + sharedPref.getSharedPrefData(SharedPref.USER_ID) + "." + fileExtension;
    StringuploadedFileLink="https://" + ApiClient.BUCKET_NAME + "." + ApiClient.AWS_END_POINT + "/" + fileName;
    returnnewRecordData(uploadedFileLink, fileExtension, fileName);
}

publicvoidprocessImageFiles(List<File> selectedImageList) {
    Observable.fromIterable(selectedImageList)
            .flatMapSingle(file -> uploadToAWS(file, toRecord(file)).subscribeOn(Schedulers.io()))
            .subscribe();
}

Post a Comment for "Uploading Multiple Image To Aws Server Using Rxjava"