本文整理匯總了Java中org.hamster.weixinmp.dao.entity.item.WxItemImageEntity類的典型用法代碼示例。如果您正苦於以下問題:Java WxItemImageEntity類的具體用法?Java WxItemImageEntity怎麽用?Java WxItemImageEntity使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
WxItemImageEntity類屬於org.hamster.weixinmp.dao.entity.item包,在下文中一共展示了WxItemImageEntity類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testMedia
import org.hamster.weixinmp.dao.entity.item.WxItemImageEntity; //導入依賴的package包/類
@Test
@Ignore
public void testMedia() throws WxException, FileNotFoundException, IOException {
File imageFile = new File("src/test/resources/media/cat.jpg");
byte[] content = IOUtils.toByteArray(new FileReader(imageFile));
WxItemImageEntity imageMedia = (WxItemImageEntity) mediaService
.remoteMediaUpload(accessToken, WxMediaTypeEnum.IMAGE, content);
System.out.println(imageMedia);
}
示例2: remoteMediaUpload
import org.hamster.weixinmp.dao.entity.item.WxItemImageEntity; //導入依賴的package包/類
public WxBaseItemMediaEntity remoteMediaUpload(String accessToken,
WxMediaTypeEnum type, byte[] content) throws WxException {
MultipartEntityBuilder entityBuilder = MultipartEntityBuilder.create();
String typeString = null;
switch (type) {
case IMAGE:
case THUMB:
case VIDEO:
case VOICE:
typeString = type.toString().toLowerCase();
break;
case MUSIC:
case DEFAULT:
case PIC_DESC:
throw new WxException("Not supported upload type : "
+ type.toString());
default:
break;
}
Map<String, String> params = WxUtil.getAccessTokenParams(accessToken);
System.out.println(typeString);
params.put("type", typeString);
ContentBody contentBody = new ByteArrayBody(content, ContentType.MULTIPART_FORM_DATA, "name.jpg");
entityBuilder.addPart("media", contentBody);
MediaResultMapper result = WxUtil.sendRequest(
config.getMediaUploadUrl(), HttpMethod.POST, params,
entityBuilder.build(), MediaResultMapper.class);
WxBaseItemMediaEntity resultEntity = null;
switch (type) {
case IMAGE:
WxItemImageEntity imageEntity = new WxItemImageEntity();
imageEntity.setMediaId(result.getMedia_id());
imageEntity.setCreatedDate(new Date(result.getCreated_at() * 1000));
resultEntity = imageEntity;
break;
case THUMB:
WxItemThumbEntity thumbEntity = new WxItemThumbEntity();
thumbEntity.setMediaId(result.getMedia_id());
thumbEntity.setCreatedDate(new Date(result.getCreated_at() * 1000));
resultEntity = thumbEntity;
break;
case VIDEO:
WxItemVideoEntity videoEntity = new WxItemVideoEntity();
videoEntity.setMediaId(result.getMedia_id());
videoEntity.setCreatedDate(new Date(result.getCreated_at() * 1000));
resultEntity = videoEntity;
break;
case VOICE:
WxItemVoiceEntity voiceEntity = new WxItemVoiceEntity();
voiceEntity.setMediaId(result.getMedia_id());
voiceEntity.setCreatedDate(new Date(result.getCreated_at() * 1000));
resultEntity = voiceEntity;
break;
case MUSIC:
case DEFAULT:
case PIC_DESC:
throw new WxException("Not supported upload type : "
+ type.toString());
default:
break;
}
return resultEntity;
}
示例3: getImage
import org.hamster.weixinmp.dao.entity.item.WxItemImageEntity; //導入依賴的package包/類
public WxItemImageEntity getImage() {
return image;
}
示例4: setImage
import org.hamster.weixinmp.dao.entity.item.WxItemImageEntity; //導入依賴的package包/類
public void setImage(WxItemImageEntity image) {
this.image = image;
}
示例5: WxRespImageEntity
import org.hamster.weixinmp.dao.entity.item.WxItemImageEntity; //導入依賴的package包/類
public WxRespImageEntity(WxItemImageEntity image) {
super();
this.image = image;
}
示例6: WxMsgImageEntity
import org.hamster.weixinmp.dao.entity.item.WxItemImageEntity; //導入依賴的package包/類
public WxMsgImageEntity(String toUserName, String fromUserName,
Long createTime, String msgType, Long msgId, WxItemImageEntity image) {
super(toUserName, fromUserName, createTime, msgType, msgId);
this.image = image;
}
示例7: getMsgImage
import org.hamster.weixinmp.dao.entity.item.WxItemImageEntity; //導入依賴的package包/類
/**
* <code>
* <xml>
* <ToUserName><![CDATA[toUser]]></ToUserName>
* <FromUserName><![CDATA[fromUser]]></FromUserName>
* <CreateTime>1348831860</CreateTime>
* <MsgType><![CDATA[image]]></MsgType>
* <PicUrl><![CDATA[this is a url]]></PicUrl>
* <MediaId><![CDATA[media_id]]></MediaId>
* <MsgId>1234567890123456</MsgId>
* </xml>
* </code>
*
* @param xmlstr
* @return
* @throws DocumentException
*/
public static WxMsgImageEntity getMsgImage(Element ele) throws DocumentException {
WxMsgImageEntity result = msgEntityFactory(WxMsgImageEntity.class, ele);
WxItemImageEntity image = new WxItemImageEntity();
image.setMediaId(strVal(ele, "MediaId"));
image.setPicUrl(strVal(ele, "PicUrl"));
result.setImage(image);
return result;
}