src/main/java/org/edgegallery/appstore/infrastructure/util/AppUtil.java
public void uploadFileToFileServer(String userId, String fileParent, File imageFolder) throws IOException {
        String imageId = "";
        String imagePath = "";
        String outPath = imageFolder.getCanonicalPath();
        List<SwImgDesc> imgDecsLists = getSwImageDescInfo(outPath);
        for (SwImgDesc imageDesc : imgDecsLists) {
            String imageName = imageDesc.getName();
            //get image name
            File fileImage = new File(outPath + File.separator + imageName + ZIP_EXTENSION);
            imagePath = fileImage.getCanonicalPath();
            //upload image file
            imageId = uploadFileUtil.uploadFile(userId, imagePath);
            if (StringUtils.isEmpty(imageId)) {
                LOGGER.error("upload to remote file server failed.");
                throw new AppException("upload to remote file server failed.",
                    ResponseConst.RET_UPLOAD_FILE_FAILED);
            }
            //update swImageJson file
            String newPathName = fileSystemAddress + "/image-management/v1/images/" + imageId + DOWNLOAD_IMAGE_TAG;
            updateJsonFileServer(imageDesc, imgDecsLists, fileParent, newPathName);
            updateRelationalFile(fileParent, imageName);
        }
    }
/**
     * upload file to FileServer.
     *
     * @param userId userId.
     * @param fileParent fileParent.
     * @param imageFolder imageFolder.
     */
upload file to FileServer.
@param userId userId.
@param fileParent fileParent.
@param imageFolder imageFolder.
upload file to FileServer . @param userId userId . @param fileParent fileParent . @param imageFolder imageFolder .
public void uploadFileToFileServer(String userId, String fileParent, File imageFolder) throws IOException {
        String imageId = "";
        String imagePath = "";
        String outPath = imageFolder.getCanonicalPath();
        List<SwImgDesc> imgDecsLists = getSwImageDescInfo(outPath);
        for (SwImgDesc imageDesc : imgDecsLists) {
            String imageName = imageDesc.getName();
            File fileImage = new File(outPath + File.separator + imageName + ZIP_EXTENSION);
            imagePath = fileImage.getCanonicalPath();
            imageId = uploadFileUtil.uploadFile(userId, imagePath);
            if (StringUtils.isEmpty(imageId)) {
                LOGGER.error("upload to remote file server failed.");
                throw new AppException("upload to remote file server failed.",
                    ResponseConst.RET_UPLOAD_FILE_FAILED);
            }
            String newPathName = fileSystemAddress + "/image-management/v1/images/" + imageId + DOWNLOAD_IMAGE_TAG;
            updateJsonFileServer(imageDesc, imgDecsLists, fileParent, newPathName);
            updateRelationalFile(fileParent, imageName);
        }
    }
public void uploadFileToFileServer ( String userId , String fileParent , File imageFolder ) throws IOException { String imageId = "" ; String imagePath = "" ; String outPath = imageFolder . getCanonicalPath ( ) ; List < SwImgDesc > imgDecsLists = getSwImageDescInfo ( outPath ) ; for ( SwImgDesc imageDesc : imgDecsLists ) { String imageName = imageDesc . getName ( ) ; File fileImage = new File ( outPath + File . separator + imageName + ZIP_EXTENSION ) ; imagePath = fileImage . getCanonicalPath ( ) ; imageId = uploadFileUtil . uploadFile ( userId , imagePath ) ; if ( StringUtils . isEmpty ( imageId ) ) { LOGGER . error ( "upload to remote file server failed." ) ; throw new AppException ( "upload to remote file server failed." , ResponseConst . RET_UPLOAD_FILE_FAILED ) ; } String newPathName = fileSystemAddress + "/image-management/v1/images/" + imageId + DOWNLOAD_IMAGE_TAG ; updateJsonFileServer ( imageDesc , imgDecsLists , fileParent , newPathName ) ; updateRelationalFile ( fileParent , imageName ) ; } }
upload file to FileServer.
upload file to FileServer .
//get image name //upload image file //update swImageJson file