java后台生成文件并上传到服务器

部分调用代码
//上传plist文件
private String generatePlistFile(SysVersionBo bo,SysVersions sv){
    byte[] bytes = generatePlistStr(bo,sv.getAppName()).getBytes();
    InputStream fileInputStream = new ByteArrayInputStream(bytes);
    try {
        StringBuilder sb = new StringBuilder();
        sb.append(packageIos).append(bo.getAppCode()).append(bo.getVersions()).append(".plist");
        //上传oss
        ossComponent.upload(fileInputStream, sb.toString());
    } catch (Exception e) {
        log.error("-->generatePlistFile error:", e);
    } finally {
        if (fileInputStream != null) {
            try {
                fileInputStream.close();
            } catch (IOException e) {
                log.error("generatePlistFile error:", e);
            }
        }
    }
    StringBuilder fileName = new StringBuilder();
    fileName.append(bo.getAppCode()).append(bo.getVersions()).append(".plist");
    //返回带有http的路径
    return ossComponent.fmtAccessIosPackageUrl(fileName.toString());
}

//拼接文件
private String generatePlistStr(SysVersionBo bo,String appName){
    if(bo.getUrl().contains("http:") ){
        bo.setUrl(bo.getUrl().replace("http:","https:"));
    }
    String bundleIdentifier = switchBundleIdentifier(bo.getAppCode());
    StringBuilder fileStr = new StringBuilder();
    fileStr.append("");
    fileStr.append("");
    fileStr.append("items");
    fileStr.append("assets");
    fileStr.append("kind");
    fileStr.append("software-packageurl");
    fileStr.append("");
    fileStr.append(bo.getUrl());
    fileStr.append("");
    fileStr.append("");
    fileStr.append("kinddisplay-image");
    fileStr.append("urlhttps://");
    fileStr.append("");
    fileStr.append("kindfull-size-image");
    fileStr.append("urlhttps://");
    fileStr.append("");
    fileStr.append("");
    fileStr.append("metadata");
    fileStr.append("");
    fileStr.append("bundle-identifier");
    fileStr.append("");
    fileStr.append(bundleIdentifier);
    fileStr.append("");
    fileStr.append("bundle-version");
    fileStr.append("");
    fileStr.append(bo.getVersions());
    fileStr.append("");
    fileStr.append("kind");
    fileStr.append("software");
    fileStr.append("title");
    fileStr.append("");
    fileStr.append(appName);
    fileStr.append("");
    fileStr.append("");
    fileStr.append("");
    return fileStr.toString();
}

你可能感兴趣的:(java,后台生成文件并上传到服务)