Improve Object Download (#867)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
This commit is contained in:
@@ -1,25 +1,25 @@
|
||||
{
|
||||
"files": {
|
||||
"main.css": "/static/css/main.8cfac526.chunk.css",
|
||||
"main.js": "/static/js/main.e4d2482a.chunk.js",
|
||||
"main.js.map": "/static/js/main.e4d2482a.chunk.js.map",
|
||||
"main.js": "/static/js/main.19a8b820.chunk.js",
|
||||
"main.js.map": "/static/js/main.19a8b820.chunk.js.map",
|
||||
"runtime-main.js": "/static/js/runtime-main.43a31377.js",
|
||||
"runtime-main.js.map": "/static/js/runtime-main.43a31377.js.map",
|
||||
"static/css/2.60e04a19.chunk.css": "/static/css/2.60e04a19.chunk.css",
|
||||
"static/js/2.f1d0208d.chunk.js": "/static/js/2.f1d0208d.chunk.js",
|
||||
"static/js/2.f1d0208d.chunk.js.map": "/static/js/2.f1d0208d.chunk.js.map",
|
||||
"static/css/2.20c81d8d.chunk.css": "/static/css/2.20c81d8d.chunk.css",
|
||||
"static/js/2.c66fcba0.chunk.js": "/static/js/2.c66fcba0.chunk.js",
|
||||
"static/js/2.c66fcba0.chunk.js.map": "/static/js/2.c66fcba0.chunk.js.map",
|
||||
"index.html": "/index.html",
|
||||
"static/css/2.60e04a19.chunk.css.map": "/static/css/2.60e04a19.chunk.css.map",
|
||||
"static/css/2.20c81d8d.chunk.css.map": "/static/css/2.20c81d8d.chunk.css.map",
|
||||
"static/css/main.8cfac526.chunk.css.map": "/static/css/main.8cfac526.chunk.css.map",
|
||||
"static/js/2.f1d0208d.chunk.js.LICENSE.txt": "/static/js/2.f1d0208d.chunk.js.LICENSE.txt",
|
||||
"static/js/2.c66fcba0.chunk.js.LICENSE.txt": "/static/js/2.c66fcba0.chunk.js.LICENSE.txt",
|
||||
"static/media/minio_console_logo.0837460e.svg": "/static/media/minio_console_logo.0837460e.svg",
|
||||
"static/media/minio_operator_logo.1312b7c9.svg": "/static/media/minio_operator_logo.1312b7c9.svg"
|
||||
},
|
||||
"entrypoints": [
|
||||
"static/js/runtime-main.43a31377.js",
|
||||
"static/css/2.60e04a19.chunk.css",
|
||||
"static/js/2.f1d0208d.chunk.js",
|
||||
"static/css/2.20c81d8d.chunk.css",
|
||||
"static/js/2.c66fcba0.chunk.js",
|
||||
"static/css/main.8cfac526.chunk.css",
|
||||
"static/js/main.e4d2482a.chunk.js"
|
||||
"static/js/main.19a8b820.chunk.js"
|
||||
]
|
||||
}
|
||||
@@ -1 +1 @@
|
||||
<!doctype html><html lang="en"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="MinIO Console"/><link href="https://fonts.googleapis.com/css2?family=Lato:wght@400;500;700;900&display=swap" rel="stylesheet"/><link rel="apple-touch-icon" sizes="180x180" href="/apple-icon-180x180.png"/><link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png"/><link rel="icon" type="image/png" sizes="96x96" href="/favicon-96x96.png"/><link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png"/><link rel="manifest" href="/manifest.json"/><link rel="mask-icon" href="/safari-pinned-tab.svg" color="#3a4e54"/><title>MinIO Console</title><link href="/static/css/2.60e04a19.chunk.css" rel="stylesheet"><link href="/static/css/main.8cfac526.chunk.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>!function(e){function r(r){for(var n,l,i=r[0],a=r[1],p=r[2],c=0,s=[];c<i.length;c++)l=i[c],Object.prototype.hasOwnProperty.call(o,l)&&o[l]&&s.push(o[l][0]),o[l]=0;for(n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n]);for(f&&f(r);s.length;)s.shift()();return u.push.apply(u,p||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,i=1;i<t.length;i++){var a=t[i];0!==o[a]&&(n=!1)}n&&(u.splice(r--,1),e=l(l.s=t[0]))}return e}var n={},o={1:0},u=[];function l(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,l),t.l=!0,t.exports}l.m=e,l.c=n,l.d=function(e,r,t){l.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},l.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},l.t=function(e,r){if(1&r&&(e=l(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(l.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)l.d(t,n,function(r){return e[r]}.bind(null,n));return t},l.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return l.d(r,"a",r),r},l.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},l.p="/";var i=this["webpackJsonpportal-ui"]=this["webpackJsonpportal-ui"]||[],a=i.push.bind(i);i.push=r,i=i.slice();for(var p=0;p<i.length;p++)r(i[p]);var f=a;t()}([])</script><script src="/static/js/2.f1d0208d.chunk.js"></script><script src="/static/js/main.e4d2482a.chunk.js"></script></body></html>
|
||||
<!doctype html><html lang="en"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="MinIO Console"/><link href="https://fonts.googleapis.com/css2?family=Lato:wght@400;500;700;900&display=swap" rel="stylesheet"/><link rel="apple-touch-icon" sizes="180x180" href="/apple-icon-180x180.png"/><link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png"/><link rel="icon" type="image/png" sizes="96x96" href="/favicon-96x96.png"/><link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png"/><link rel="manifest" href="/manifest.json"/><link rel="mask-icon" href="/safari-pinned-tab.svg" color="#3a4e54"/><title>MinIO Console</title><link href="/static/css/2.20c81d8d.chunk.css" rel="stylesheet"><link href="/static/css/main.8cfac526.chunk.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>!function(e){function r(r){for(var n,l,i=r[0],a=r[1],p=r[2],c=0,s=[];c<i.length;c++)l=i[c],Object.prototype.hasOwnProperty.call(o,l)&&o[l]&&s.push(o[l][0]),o[l]=0;for(n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n]);for(f&&f(r);s.length;)s.shift()();return u.push.apply(u,p||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,i=1;i<t.length;i++){var a=t[i];0!==o[a]&&(n=!1)}n&&(u.splice(r--,1),e=l(l.s=t[0]))}return e}var n={},o={1:0},u=[];function l(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,l),t.l=!0,t.exports}l.m=e,l.c=n,l.d=function(e,r,t){l.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},l.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},l.t=function(e,r){if(1&r&&(e=l(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(l.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)l.d(t,n,function(r){return e[r]}.bind(null,n));return t},l.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return l.d(r,"a",r),r},l.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},l.p="/";var i=this["webpackJsonpportal-ui"]=this["webpackJsonpportal-ui"]||[],a=i.push.bind(i);i.push=r,i=i.slice();for(var p=0;p<i.length;p++)r(i[p]);var f=a;t()}([])</script><script src="/static/js/2.c66fcba0.chunk.js"></script><script src="/static/js/main.19a8b820.chunk.js"></script></body></html>
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
portal-ui/build/static/js/main.19a8b820.chunk.js.map
Normal file
1
portal-ui/build/static/js/main.19a8b820.chunk.js.map
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -552,7 +552,6 @@ const ListObjects = ({
|
||||
};
|
||||
|
||||
const downloadObject = (object: BucketObject) => {
|
||||
fileIsBeingPrepared(`${selectedBucket}/${object.name}`);
|
||||
if (object.size > 104857600) {
|
||||
// If file is bigger than 100MB we show a notification
|
||||
setSnackBarMessage(
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import React, { useState, useEffect } from "react";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { connect } from "react-redux";
|
||||
import get from "lodash/get";
|
||||
import * as reactMoment from "react-moment";
|
||||
@@ -36,9 +36,9 @@ import {
|
||||
} from "../../../../Common/FormComponents/common/styleLibrary";
|
||||
import { IFileInfo } from "./types";
|
||||
import {
|
||||
removeRouteLevel,
|
||||
fileIsBeingPrepared,
|
||||
fileDownloadStarted,
|
||||
fileIsBeingPrepared,
|
||||
removeRouteLevel,
|
||||
} from "../../../../ObjectBrowser/actions";
|
||||
import {
|
||||
ObjectBrowserReducer,
|
||||
@@ -62,8 +62,8 @@ import AddTagModal from "./AddTagModal";
|
||||
import DeleteTagModal from "./DeleteTagModal";
|
||||
import SetLegalHoldModal from "./SetLegalHoldModal";
|
||||
import {
|
||||
setSnackBarMessage,
|
||||
setErrorSnackMessage,
|
||||
setSnackBarMessage,
|
||||
} from "../../../../../../actions";
|
||||
import { CircularProgress } from "@material-ui/core";
|
||||
|
||||
@@ -274,11 +274,6 @@ const ObjectDetails = ({
|
||||
};
|
||||
|
||||
const downloadObject = (object: IFileInfo, includeVersion?: boolean) => {
|
||||
fileIsBeingPrepared(
|
||||
`${bucketName}/${object.name}${
|
||||
includeVersion ? `-${object.version_id}` : ""
|
||||
}`
|
||||
);
|
||||
if (object.size && parseInt(object.size) > 104857600) {
|
||||
// If file is bigger than 100MB we show a notification
|
||||
setSnackBarMessage(
|
||||
@@ -312,11 +307,6 @@ const ObjectDetails = ({
|
||||
onClick: (item: IFileInfo) => {
|
||||
downloadObject(item, true);
|
||||
},
|
||||
showLoaderFunction: (version: string) => {
|
||||
return downloadingFiles.includes(
|
||||
`${bucketName}/${objectName}-${version}`
|
||||
);
|
||||
},
|
||||
disableButtonFunction: (item: string) => {
|
||||
const element = versions.find((elm) => elm.version_id === item);
|
||||
if (element && element.is_delete_marker) {
|
||||
|
||||
@@ -25,40 +25,11 @@ export const download = (
|
||||
) => {
|
||||
const anchor = document.createElement("a");
|
||||
document.body.appendChild(anchor);
|
||||
const xhr = new XMLHttpRequest();
|
||||
const allPathData = objectPath.split("/");
|
||||
const objectName = allPathData[allPathData.length - 1];
|
||||
|
||||
let path = `/api/v1/buckets/${bucketName}/objects/download?prefix=${objectPath}`;
|
||||
if (!isNullOrUndefined(versionID) && versionID !== "null") {
|
||||
path = path.concat(`&version_id=${versionID}`);
|
||||
}
|
||||
|
||||
xhr.open("GET", path, true);
|
||||
xhr.responseType = "blob";
|
||||
|
||||
xhr.onload = function (e) {
|
||||
if (this.status === 200) {
|
||||
const blob = new Blob([this.response], {
|
||||
type: "octet/stream",
|
||||
});
|
||||
const blobUrl = window.URL.createObjectURL(blob);
|
||||
|
||||
anchor.href = blobUrl;
|
||||
anchor.download = objectName;
|
||||
|
||||
anchor.click();
|
||||
window.URL.revokeObjectURL(blobUrl);
|
||||
anchor.remove();
|
||||
|
||||
if (callBack) {
|
||||
callBack(
|
||||
`${bucketName}/${objectPath}${
|
||||
includeVersionInCallback ? `-${versionID}` : ""
|
||||
}`
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
xhr.send();
|
||||
window.location.href = path;
|
||||
};
|
||||
|
||||
@@ -74,9 +74,7 @@ func startConsoleLog(ctx context.Context, conn WSConn, client MinioAdmin) error
|
||||
func serializeConsoleLogInfo(l *madmin.LogInfo) (logInfo madmin.LogInfo) {
|
||||
logInfo = *l
|
||||
if logInfo.ConsoleMsg != "" {
|
||||
if strings.HasPrefix(logInfo.ConsoleMsg, "\n") {
|
||||
logInfo.ConsoleMsg = strings.TrimPrefix(logInfo.ConsoleMsg, "\n")
|
||||
}
|
||||
logInfo.ConsoleMsg = strings.TrimPrefix(logInfo.ConsoleMsg, "\n")
|
||||
}
|
||||
if logInfo.Time != "" {
|
||||
logInfo.Time = getLogTime(logInfo.Time)
|
||||
|
||||
@@ -20,6 +20,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
@@ -68,11 +69,22 @@ func registerObjectsHandlers(api *operations.ConsoleAPI) {
|
||||
return user_api.NewDownloadObjectDefault(int(err.Code)).WithPayload(err)
|
||||
}
|
||||
return middleware.ResponderFunc(func(rw http.ResponseWriter, _ runtime.Producer) {
|
||||
x, err := io.Copy(rw, resp)
|
||||
|
||||
fmt.Println(x)
|
||||
fmt.Println(err)
|
||||
|
||||
// indicate it's a download to the browser, and the size of the object
|
||||
rw.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=\"%s\"", params.Prefix))
|
||||
rw.Header().Set("Content-Type", "application/octet-stream")
|
||||
// indicate object size
|
||||
stat, err := resp.(*minio.Object).Stat()
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
} else {
|
||||
rw.Header().Set("Content-Length", fmt.Sprintf("%d", stat.Size))
|
||||
rw.Header().Set("Content-Type", stat.ContentType)
|
||||
}
|
||||
// Copy the stream
|
||||
_, err = io.Copy(rw, resp)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
resp.Close()
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user