mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-09-20 02:29:44 +08:00
增加临时文件目录配置
在下载多媒体文件下载时可以指定临时文件目录。
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package me.chanjar.weixin.cp.api;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import me.chanjar.weixin.common.bean.WxAccessToken;
|
||||
|
||||
/**
|
||||
@@ -58,5 +60,7 @@ public interface WxCpConfigStorage {
|
||||
public String getHttp_proxy_username();
|
||||
|
||||
public String getHttp_proxy_password();
|
||||
|
||||
public File getTmpDirFile();
|
||||
|
||||
}
|
||||
|
@@ -1,5 +1,7 @@
|
||||
package me.chanjar.weixin.cp.api;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import me.chanjar.weixin.common.bean.WxAccessToken;
|
||||
|
||||
/**
|
||||
@@ -28,6 +30,8 @@ public class WxCpInMemoryConfigStorage implements WxCpConfigStorage {
|
||||
protected volatile String jsapiTicket;
|
||||
protected volatile long jsapiTicketExpiresTime;
|
||||
|
||||
protected volatile File tmpDirFile;
|
||||
|
||||
public String getAccessToken() {
|
||||
return this.accessToken;
|
||||
}
|
||||
@@ -189,7 +193,16 @@ public class WxCpInMemoryConfigStorage implements WxCpConfigStorage {
|
||||
", http_proxy_password='" + http_proxy_password + '\'' +
|
||||
", jsapiTicket='" + jsapiTicket + '\'' +
|
||||
", jsapiTicketExpiresTime='" + jsapiTicketExpiresTime + '\'' +
|
||||
", tmpDirFile='" + tmpDirFile + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
public File getTmpDirFile() {
|
||||
return tmpDirFile;
|
||||
}
|
||||
|
||||
public void setTmpDirFile(File tmpDirFile) {
|
||||
this.tmpDirFile = tmpDirFile;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -78,6 +78,11 @@ public class WxCpServiceImpl implements WxCpService {
|
||||
|
||||
protected WxSessionManager sessionManager = new StandardSessionManager();
|
||||
|
||||
/**
|
||||
* 临时文件目录
|
||||
*/
|
||||
protected File tmpDirFile;
|
||||
|
||||
public boolean checkSignature(String msgSignature, String timestamp, String nonce, String data) {
|
||||
try {
|
||||
return SHA1.gen(wxCpConfigStorage.getToken(), timestamp, nonce, data).equals(msgSignature);
|
||||
@@ -236,7 +241,8 @@ public class WxCpServiceImpl implements WxCpService {
|
||||
|
||||
public File mediaDownload(String media_id) throws WxErrorException {
|
||||
String url = "https://qyapi.weixin.qq.com/cgi-bin/media/get";
|
||||
return execute(new MediaDownloadRequestExecutor(), url, "media_id=" + media_id);
|
||||
|
||||
return execute(new MediaDownloadRequestExecutor(wxCpConfigStorage.getTmpDirFile()), url, "media_id=" + media_id);
|
||||
}
|
||||
|
||||
|
||||
@@ -638,6 +644,14 @@ public class WxCpServiceImpl implements WxCpService {
|
||||
public void setSessionManager(WxSessionManager sessionManager) {
|
||||
this.sessionManager = sessionManager;
|
||||
}
|
||||
|
||||
public File getTmpDirFile() {
|
||||
return tmpDirFile;
|
||||
}
|
||||
|
||||
public void setTmpDirFile(File tmpDirFile) {
|
||||
this.tmpDirFile = tmpDirFile;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Float a = 3.1f;
|
||||
|
Reference in New Issue
Block a user