<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                # 我的文檔安全配置 jeecg-boot 提供了文檔管理的功能,授權文檔管理菜單后可上傳文檔,也可將文檔授權給不同用戶、角色及部門。 但文檔上傳至云服務器時會涉及到文件的安全問題,目前jeecg-boot通過設置私有桶來保證安全問題。 [TOC] ## 1. 在org.jeecg.common.constant.CommonConstant.java中設置文檔上傳自定義桶及路徑 文檔上傳時,如果桶名稱存在,則直接使用,如果不存在,則創建一個新的桶,默認不設置公開讀寫權限 ~~~ /** * 文檔上傳自定義桶名稱 */ public static final String UPLOAD_CUSTOM_BUCKET = "eoafile"; /** * 文檔上傳自定義路徑 */ public static final String UPLOAD_CUSTOM_PATH = "eoafile"; /** * Minio文件外鏈接有效天數 */ public static final Integer UPLOAD_EFFECTIVE_DAYS = 1; ~~~ ## 2. 文檔下載時,通過獲取文件流的方式下載 ~~~ /** * Minio 獲取文件流 * @param bucketName 桶名稱 * @param objectName 文件名 * @return */ public static InputStream getMinioFile(String bucketName,String objectName){ InputStream inputStream = null; try { initMinio(minioUrl, minioName, minioPass); inputStream = minioClient.getObject(bucketName, objectName); } catch (Exception e) { log.info("文件獲取失敗" + e.getMessage()); } return inputStream; } /** * OSS 獲取文件流 * @param objectName 文件名 * @param bucket 桶名稱 * @return */ public static InputStream getOssFile(String objectName,String bucket){ InputStream inputStream = null; try{ String newBucket = bucketName; if(oConvertUtils.isNotEmpty(bucket)){ newBucket = bucket; } initOSS(endPoint, accessKeyId, accessKeySecret); OSSObject ossObject = ossClient.getObject(newBucket,objectName); inputStream = new BufferedInputStream(ossObject.getObjectContent()); }catch (Exception e){ log.info("文件獲取失敗" + e.getMessage()); } return inputStream; } ~~~ ## 3. 文檔預覽時,通過獲取文件授權路徑 可自定義設置有效時間 ~~~ /** * Minio 獲取文件外鏈 * @param bucketName 桶名稱 * @param objectName 文件名 * @param expires 有效時間 * @return */ public static String getObjectURL(String bucketName, String objectName, Integer expires) { initMinio(minioUrl, minioName,minioPass); try{ String url = minioClient.presignedGetObject(bucketName, objectName, expires); return URLDecoder.decode(url,"UTF-8"); }catch (Exception e){ log.info("文件路徑獲取失敗" + e.getMessage()); } return null; } /** * OSS 獲取文件外鏈 * @param bucketName 桶名稱 * @param objectName 文件名 * @param expires 有效時間 * @return */ public static String getObjectURL(String bucketName, String objectName, Date expires) { initOSS(endPoint, accessKeyId, accessKeySecret); try{ if(ossClient.doesObjectExist(bucketName,objectName)){ URL url = ossClient.generatePresignedUrl(bucketName,objectName,expires); return URLDecoder.decode(url.toString(),"UTF-8"); } }catch (Exception e){ log.info("文件路徑獲取失敗" + e.getMessage()); } return null; } ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看