src/main/java/org/edgegallery/appstore/interfaces/app/facade/AppServiceFacade.java
public ResponseEntity<byte[]> downloadDemoVideo(String appId) {
        App app = appRepository.find(appId)
            .orElseThrow(() -> new EntityNotFoundException(App.class, appId, ResponseConst.RET_APP_NOT_FOUND));
        Release release = app.findLatestRelease()
            .orElseThrow(() -> new EntityNotFoundException(App.class, appId, ResponseConst.RET_APP_NOT_FOUND));
        byte[] image = new byte[0];
        HttpHeaders headers = new HttpHeaders();
        headers.add(CONTENT_TYPE, "video/mp4");
        if (release.getDemoVideo() != null && release.getDemoVideo().getStorageAddress() != null) {
            try {
                image = Files.readAllBytes(new File(release.getDemoVideo().getStorageAddress()).toPath());
            } catch (IOException e) {
                LOGGER.error("get download video error: {}", e.getMessage());
            }
            String fileName = appUtil.getFileName(release, release.getDemoVideo());
            headers.setContentLength(image.length);
            headers.add(CONTENT_DISPOSITION, HEADER_VALUE + fileName);
        }
        return ResponseEntity.ok().headers(headers).body(image);
    }
/**
     * Download demo video by app id.
     *
     * @param appId app id.
     * @return video entity
     */
Download demo video by app id.
@param appId app id.
@return video entity
Download demo video by app id . @param appId app id . @return video entity
public ResponseEntity<byte[]> downloadDemoVideo(String appId) {
        App app = appRepository.find(appId)
            .orElseThrow(() -> new EntityNotFoundException(App.class, appId, ResponseConst.RET_APP_NOT_FOUND));
        Release release = app.findLatestRelease()
            .orElseThrow(() -> new EntityNotFoundException(App.class, appId, ResponseConst.RET_APP_NOT_FOUND));
        byte[] image = new byte[0];
        HttpHeaders headers = new HttpHeaders();
        headers.add(CONTENT_TYPE, "video/mp4");
        if (release.getDemoVideo() != null && release.getDemoVideo().getStorageAddress() != null) {
            try {
                image = Files.readAllBytes(new File(release.getDemoVideo().getStorageAddress()).toPath());
            } catch (IOException e) {
                LOGGER.error("get download video error: {}", e.getMessage());
            }
            String fileName = appUtil.getFileName(release, release.getDemoVideo());
            headers.setContentLength(image.length);
            headers.add(CONTENT_DISPOSITION, HEADER_VALUE + fileName);
        }
        return ResponseEntity.ok().headers(headers).body(image);
    }
public ResponseEntity < byte [ ] > downloadDemoVideo ( String appId ) { App app = appRepository . find ( appId ) . orElseThrow ( ( ) -> new EntityNotFoundException ( App . class , appId , ResponseConst . RET_APP_NOT_FOUND ) ) ; Release release = app . findLatestRelease ( ) . orElseThrow ( ( ) -> new EntityNotFoundException ( App . class , appId , ResponseConst . RET_APP_NOT_FOUND ) ) ; byte [ ] image = new byte [ 0 ] ; HttpHeaders headers = new HttpHeaders ( ) ; headers . add ( CONTENT_TYPE , "video/mp4" ) ; if ( release . getDemoVideo ( ) != null && release . getDemoVideo ( ) . getStorageAddress ( ) != null ) { try { image = Files . readAllBytes ( new File ( release . getDemoVideo ( ) . getStorageAddress ( ) ) . toPath ( ) ) ; } catch ( IOException e ) { LOGGER . error ( "get download video error: {}" , e . getMessage ( ) ) ; } String fileName = appUtil . getFileName ( release , release . getDemoVideo ( ) ) ; headers . setContentLength ( image . length ) ; headers . add ( CONTENT_DISPOSITION , HEADER_VALUE + fileName ) ; } return ResponseEntity . ok ( ) . headers ( headers ) . body ( image ) ; }
Download demo video by app id.
Download demo video by app id .