Utilities
Update time: 2023/10/11 08:36:17
Log file compression
Compress the log file into zip format, and return it to a specified path for zip file.
- API prototype
java/**
* Compress log files to zip
* @return - Return path of zip package
*/
InvocationFuture<String> zipLogs();
- Example
javaNIMClient.getService(MiscService.class).zipLogs().setCallback(new RequestCallback<String>() {
@Override
public void onSuccess(String path) {
// Toast path
}
@Override
public void onFailed(int code) {
}
@Override
public void onException(Throwable exception) {
}
});
Getting the size of SDK cache files
Compute the size of SDK cache file, for example, thumbnails of transmitted or received image messages, audio messages, recording file.
- API prototype
java/**
* Get the size of SDK specified cache file
* @param fileTypes - List of file types
* @param startTime - Start time (unit: ms). If it is set to 0, start time is not limited.
* @param startTime - End time (unit: ms). If it is set to 0, end time is not limited.
* @return - Cache size
*/
InvocationFuture<Long> getSizeOfDirCache(List<DirCacheFileType> fileTypes, long startTime, long endTime);
- Example
java
List<DirCacheFileType> fileTypes = new ArrayList<>();
fileTypes.add(DirCacheFileType.THUMB);
fileTypes.add(DirCacheFileType.IMAGE);
fileTypes.add(DirCacheFileType.AUDIO);
NIMClient.getService(MiscService.class).getSizeOfDirCache(fileTypes, 0, 0).setCallback(new RequestCallback<Long>() {
@Override
public void onSuccess(Long size) {
// Calculated cache size, unit: byte
}
@Override
public void onFailed(int code) {
}
@Override
public void onException(Throwable exception) {
}
});
Deleting the SDK local cache
Delete specified SDK cache files, for example, thumbnail of transmitted or received image messages, audio messages, recording file.
- API prototype
java/**
* Delete a local cache
* @param fileTypes - List of file types
* @param startTime - Start time (unit: ms). If it is set to 0, start time is not limited.
* @param startTime - End time (unit: ms). If it is set to 0, end time is not limited.
* @return - Cache size
*/
InvocationFuture<Void> clearDirCache(List<DirCacheFileType> fileTypes, long startTime, long endTime);
- Example
java
List<DirCacheFileType> fileTypes = new ArrayList<>();
fileTypes.add(DirCacheFileType.THUMB);
fileTypes.add(DirCacheFileType.IMAGE);
fileTypes.add(DirCacheFileType.AUDIO);
NIMClient.getService(MiscService.class).clearDirCache(fileTypes, 0, 0).setCallback(new RequestCallback<Void>() {
@Override
public void onSuccess(Void size) {
// Delete successfully
}
@Override
public void onFailed(int code) {
}
@Override
public void onException(Throwable exception) {
}
});
Uploading log messages
- API prototype
java/**
* Upload log messages
* @param cut true: Partially uploaded; false: All uploaded
* @param roomId - Chat room ID. If no value is specified, enter "".
* @param uploadMsg SDK - Postscript for uploading logs. Optional. The maximum size is 4096 characters.
*
* @return InvocationFuture
*/
InvocationFuture<String> getSdkLogUpload(boolean cut, String roomId, String uploadMsg);
- Parameters
Parameter | Description |
---|---|
cut | true: Partially uploaded; false: All uploaded |
roomId | Chat Room ID. If no room ID is specified, enter "". |
uploadMsg | Postscript for uploading SDK logs. Optional. The maximum size is 4096 characters. |
- Example
javaNIMClient.getService(MiscService.class).getSdkLogUpload(true,roomIdEdit.getText().toString(),uploadMsgEdit.getText().toString()).setCallback(new RequestCallbackWrapper<String>() {
@Override
public void onResult(int code, String result, Throwable exception) {
logInfoView.setText("code="+ code + ",result="+result);
Log.d("uploadlog","result:"+result);
}
});
Was this page helpful?