All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hn.im.easemob.api.impl.EasemobFile Maven / Gradle / Ivy

There is a newer version: 1.0.18
Show newest version
package com.hn.im.easemob.api.impl;


import com.hn.im.easemob.api.EasemobRestAPI;
import com.hn.im.easemob.api.FileAPI;
import com.hn.im.easemob.comm.helper.HeaderHelper;
import com.hn.im.easemob.comm.wrapper.HeaderWrapper;

import java.io.File;

public class EasemobFile extends EasemobRestAPI implements FileAPI {
    private static final String ROOT_URI = "/chatfiles";

    @Override
    public String getResourceRootURI() {
        return ROOT_URI;
    }

    public Object uploadFile(Object file) {
        String url = getContext().getSeriveURL() + getResourceRootURI();
        HeaderWrapper header = HeaderHelper.getUploadHeaderWithToken();

        return getInvoker().uploadFile(url, header, (File) file);
    }

    public Object downloadFile(String fileUUID, String shareSecret, Boolean isThumbnail) {
        String url = getContext().getSeriveURL() + getResourceRootURI() + "/" + fileUUID;
        HeaderWrapper header = HeaderHelper.getDownloadHeaderWithToken(shareSecret, isThumbnail);

        return getInvoker().downloadFile(url, header, null);
    }

	public Object downloadFile(String url) {
		  return getInvoker().downloadFile(url);
	}
    
    
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy