上传图片素材

@param accessToken accessToken
@param type        Icon：摇一摇页面展示的icon图；License：申请开通摇一摇周边功能时需上传的资质文件；若不传type，则默认type=icon
@param inputStream inputStream
@return result
325160
public static MaterialAddResult materialAdd(String accessToken,
                                                MediaType type, InputStream inputStream) {
        HttpPost httpPost = new HttpPost(BASE_URI + "/shakearound/material/add");
        byte[] data;
        try {
            data = StreamUtils.copyToByteArray(inputStream);
        } catch (IOException e) {
            logger.error("", e);
            throw new RuntimeException(e);
        }

        MultipartEntityBuilder multipartEntityBuilder = MultipartEntityBuilder
                .create().addBinaryBody("media", data, ContentType.DEFAULT_BINARY, "temp." + type.fileSuffix());
        HttpEntity reqEntity = multipartEntityBuilder
                .addTextBody(PARAM_ACCESS_TOKEN, API.accessToken(accessToken))
                .addTextBody("type", type.uploadType()).build();
        httpPost.setEntity(reqEntity);

        return LocalHttpClient.executeJsonResult(httpPost,
                MaterialAddResult.class);
    }
237790
public static PageSearchResult pageSearch(String accessToken,
                                              PageSearch pageSearch) {
        return pageSearch(accessToken, JsonUtil.toJSONString(pageSearch));
    }
471631
public OauthData getOauthData(String apiKey, String secretKey, TokenType grantType, boolean autoSetRequestToken)
            throws SignitException {
        if (apiKey == null || secretKey == null) {
            throw new SignitException("请完善开发者账户数据");
        }
        TokenType tmpGrantType = grantType != null ? grantType : TokenType.CLIENT_CREDENTIALS;
        String response = httpClient.withAuth(auth)
                .withGetParam(RequestParam.CLIENT_ID, apiKey)
                .withGetParam(RequestParam.CLIENT_SECRET, secretKey)
                .withGetParam(RequestParam.GRANT_TYPE, tmpGrantType.name()
                        .toLowerCase())
                .get(OAUTH_TOKEN_URL)
                .getLastResponse();
        JSONObject data = JSON.parseObject(Validator.notNull(response, "请求token数据失败"));
        if (data != null && autoSetRequestToken) {
            auth.setAccessToken(Validator.notNull(data.getString("access_token"), "token获取失败"));
        }
        return FastjsonDecoder.decodeAsBean(response, OauthData.class);
    }
173329
public static StatisticsDeviceResult statisticsDevice(String accessToken,
                                                          StatisticsDevice statisticsDevice) {
        return statisticsDevice(accessToken,
                JsonUtil.toJSONString(statisticsDevice));
    }
1026044
public static CodeGetResult codeGet(String accessToken, CodeGet codeGet) {
		return codeGet(accessToken, JsonUtil.toJSONString(codeGet));
	}
982543
AuthenticationResult acquireAccessTokenFromRefreshToken(String resource, String refreshToken, boolean isMultipleResourceRefreshToken) throws IOException {
        ExecutorService executor = Executors.newSingleThreadExecutor();
        try {
            return refreshTokenClient.refreshToken(domain(), clientId(), resource, refreshToken, isMultipleResourceRefreshToken);
        } catch (Exception e) {
            return null;
        } finally {
            executor.shutdown();
        }
    }
905286
public static MpNewsGetHtmlResult mpNewsGetHtml(String accessToken, MpNewsGetHtml mpnews) {
		return mpNewsGetHtml(accessToken, JsonUtil.toJSONString(mpnews));
	}
51499
public Auth checkToken(OAuth1Token accessToken) throws FlickrException {
        return checkToken(accessToken.getToken(), accessToken.getTokenSecret());
    }
569176
public static MaterialAddResult materialAdd(String accessToken,
                                                MediaType type, File media) {
        HttpPost httpPost = new HttpPost(BASE_URI + "/shakearound/material/add");
        FileBody bin = new FileBody(media);
        MultipartEntityBuilder multipartEntityBuilder = MultipartEntityBuilder
                .create().addPart("media", bin);
        HttpEntity reqEntity = multipartEntityBuilder
                .addTextBody(PARAM_ACCESS_TOKEN, API.accessToken(accessToken))
                .addTextBody("type", type.name()).build();
        httpPost.setEntity(reqEntity);
        return LocalHttpClient.executeJsonResult(httpPost,
                MaterialAddResult.class);
    }
1280919
public GitlabHTTPRequestor authenticate(String token, TokenType type, AuthMethod method) {
        this.apiToken = token;
        this.tokenType = type;
        this.authMethod = method;
        return this;
    }
317167
private void uploadThumbImage(StorageNode client, InputStream inputStream,
                                  String masterFilename, FastImageFile fastImageFile) {
        ByteArrayInputStream thumbImageStream = null;
        ThumbImage thumbImage = fastImageFile.getThumbImage();
        try {
            //生成缩略图片
            thumbImageStream = generateThumbImageStream(inputStream, thumbImage);
            // 获取文件大小
            long fileSize = thumbImageStream.available();
            // 获取配置缩略图前缀
            String prefixName = thumbImage.getPrefixName();
            LOGGER.error("获取到缩略图前缀{}", prefixName);
            StorageUploadSlaveFileCommand command = new StorageUploadSlaveFileCommand(thumbImageStream, fileSize,
                    masterFilename, prefixName, fastImageFile.getFileExtName());
            connectionManager.executeFdfsCmd(client.getInetSocketAddress(), command);

        } catch (IOException e) {
            LOGGER.error("upload ThumbImage error", e);
            throw new FdfsUploadImageException("upload ThumbImage error", e.getCause());
        } finally {
            IOUtils.closeQuietly(thumbImageStream);
        }
    }
1034388
public void registerAccessTokenListener(AccessTokenListener accessTokenListener) {
    for(Authentication auth : authentications.values()) {
      if (auth instanceof OAuth) {
        OAuth oauth = (OAuth) auth;
        oauth.registerAccessTokenListener(accessTokenListener);
        return;
      }
    }
  }
338973
@Nonnull
  public static AccessToken createAccessTokenValidFromNow (@Nullable final String sTokenString)
  {
    // Length 66 so that the Base64 encoding does not add the "==" signs
    // Length must be dividable by 3
    final String sRealTokenString = StringHelper.hasText (sTokenString) ? sTokenString : createNewTokenString (66);
    return new AccessToken (sRealTokenString, PDTFactory.getCurrentLocalDateTime (), null, new RevocationStatus ());
  }
620797
public RefreshTokenResponse refreshToken(String grantType, String refreshToken) throws ApiException {
        ApiResponse<RefreshTokenResponse> resp = refreshTokenWithHttpInfo(grantType, refreshToken);
        return resp.getData();
    }
409563
public static DeviceBindLocationResult deviceBindLocation(
            String accessToken, DeviceBindLocation deviceBindLocation) {
        return deviceBindLocation(accessToken,
                JsonUtil.toJSONString(deviceBindLocation));
    }
774037
public static ShopGetResult shopGet(String accessToken, ShopInfo shopInfo) {
        return shopGet(accessToken, JsonUtil.toJSONString(shopInfo));
    }
1308502
public static CreateResult create(String accessToken, CashCard cashCard) {
		Create<CashCard> card = new Create<CashCard>();
		card.setCard(cashCard);
		return create(accessToken, card);
	}