/** 构造HttpPut */ protected HttpUriRequest generateHttpRequest() { // 生成Http请求 String resource = httpTool.generateCanonicalizedResource( "/" + objectGroup.getBucketName() + "/" + objectGroup.getName()); String requestUri = OSS_END_POINT + resource; HttpPut httpPut = new HttpPut(requestUri); // 构造HttpPut String authorization = OSSHttpTool.generateAuthorization( accessId, accessKey, httpMethod.toString(), "", objectGroupMetaData.getContentType(), Helper.getGMTDate(), OSSHttpTool.generateCanonicalizedHeader(objectGroupMetaData.getAttrs()), resource); httpPut.setHeader(AUTHORIZATION, authorization); httpPut.setHeader(DATE, Helper.getGMTDate()); httpPut.setHeader(HOST, OSS_HOST); try { httpPut.setEntity(new StringEntity(generateHttpEntity())); } catch (UnsupportedEncodingException e) { // Log.e(this.getClass().getName(), e.getMessage()); } return httpPut; }
/* (non-Javadoc) * @see com.aliyun.android.oss.task.Task#checkArguments() */ @Override protected void checkArguments() { if (Helper.isEmptyString(objectGroup.getBucketName()) || Helper.isEmptyString(objectGroup.getName())) { throw new IllegalArgumentException("bucketName or objectKey not set"); } if (objectGroup.getParts() == null || objectGroup.getParts().isEmpty()) { throw new IllegalArgumentException("partList not set"); } }
/** 得到FileGroup列表的Xml * @return xml */ private String generateHttpEntity() { PartsXmlSerializer serializer = new PartsXmlSerializer("CreateFileGroup"); return serializer.serialize(objectGroup.getParts()); }