mirror of
https://github.com/minio/minio.git
synced 2025-04-21 19:14:39 -04:00
Allow uploading folders on supported browsers. (#9627)
This commit is contained in:
parent
cdd6c9f52e
commit
2d7a96342c
@ -48,18 +48,29 @@ export class Dropzone extends React.Component {
|
|||||||
const rejectStyle = {
|
const rejectStyle = {
|
||||||
backgroundColor: "#ffdddd"
|
backgroundColor: "#ffdddd"
|
||||||
}
|
}
|
||||||
|
const getStyle = (isDragActive, isDragAccept, isDragReject) => ({
|
||||||
|
...style,
|
||||||
|
...(isDragActive ? activeStyle : {}),
|
||||||
|
...(isDragReject ? rejectStyle : {})
|
||||||
|
})
|
||||||
|
|
||||||
// disableClick means that it won't trigger a file upload box when
|
// disableClick means that it won't trigger a file upload box when
|
||||||
// the user clicks on a file.
|
// the user clicks on a file.
|
||||||
return (
|
return (
|
||||||
<ReactDropzone
|
<ReactDropzone
|
||||||
style={style}
|
|
||||||
activeStyle={activeStyle}
|
|
||||||
rejectStyle={rejectStyle}
|
|
||||||
disableClick={true}
|
|
||||||
onDrop={this.onDrop.bind(this)}
|
onDrop={this.onDrop.bind(this)}
|
||||||
>
|
>
|
||||||
{this.props.children}
|
{({getRootProps, getInputProps, isDragActive, isDragAccept, isDragReject}) => (
|
||||||
|
<div
|
||||||
|
{...getRootProps({
|
||||||
|
onClick: event => event.stopPropagation()
|
||||||
|
})}
|
||||||
|
style={getStyle(isDragActive, isDragAccept, isDragReject)}
|
||||||
|
>
|
||||||
|
<input {...getInputProps()} />
|
||||||
|
{this.props.children}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</ReactDropzone>
|
</ReactDropzone>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -89,11 +89,16 @@ export const uploadFile = file => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
const currentPrefix = getCurrentPrefix(state)
|
const currentPrefix = getCurrentPrefix(state)
|
||||||
const objectName = `${currentPrefix}${file.name}`
|
var _filePath = file.path || file.name
|
||||||
|
if (_filePath.charAt(0) == '/') {
|
||||||
|
_filePath = _filePath.substring(1)
|
||||||
|
}
|
||||||
|
const filePath = _filePath
|
||||||
|
const objectName = `${currentPrefix}${filePath}`
|
||||||
const uploadUrl = `${
|
const uploadUrl = `${
|
||||||
window.location.origin
|
window.location.origin
|
||||||
}${minioBrowserPrefix}/upload/${currentBucket}/${objectName}`
|
}${minioBrowserPrefix}/upload/${currentBucket}/${objectName}`
|
||||||
const slug = `${currentBucket}-${currentPrefix}-${file.name}`
|
const slug = `${currentBucket}-${currentPrefix}-${filePath}`
|
||||||
|
|
||||||
let xhr = new XMLHttpRequest()
|
let xhr = new XMLHttpRequest()
|
||||||
xhr.open("PUT", uploadUrl, true)
|
xhr.open("PUT", uploadUrl, true)
|
||||||
@ -141,7 +146,7 @@ export const uploadFile = file => {
|
|||||||
dispatch(
|
dispatch(
|
||||||
alertActions.set({
|
alertActions.set({
|
||||||
type: "success",
|
type: "success",
|
||||||
message: "File '" + file.name + "' uploaded successfully."
|
message: "File '" + filePath + "' uploaded successfully."
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
dispatch(objectsActions.selectPrefix(currentPrefix))
|
dispatch(objectsActions.selectPrefix(currentPrefix))
|
||||||
@ -153,7 +158,7 @@ export const uploadFile = file => {
|
|||||||
dispatch(
|
dispatch(
|
||||||
alertActions.set({
|
alertActions.set({
|
||||||
type: "danger",
|
type: "danger",
|
||||||
message: "Error occurred uploading '" + file.name + "'."
|
message: "Error occurred uploading '" + filePath + "'."
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
55
browser/package-lock.json
generated
55
browser/package-lock.json
generated
@ -2368,19 +2368,9 @@
|
|||||||
"integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg=="
|
"integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg=="
|
||||||
},
|
},
|
||||||
"attr-accept": {
|
"attr-accept": {
|
||||||
"version": "1.1.3",
|
"version": "2.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/attr-accept/-/attr-accept-1.1.3.tgz",
|
"resolved": "https://registry.npmjs.org/attr-accept/-/attr-accept-2.1.0.tgz",
|
||||||
"integrity": "sha512-iT40nudw8zmCweivz6j58g+RT33I4KbaIvRUhjNmDwO2WmsQUxFEZZYZ5w3vXe5x5MX9D7mfvA/XaLOZYFR9EQ==",
|
"integrity": "sha512-sLzVM3zCCmmDtDNhI0i96k6PUztkotSOXqE4kDGQt/6iDi5M+H0srjeF+QC6jN581l4X/Zq3Zu/tgcErEssavg=="
|
||||||
"requires": {
|
|
||||||
"core-js": "^2.5.0"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"core-js": {
|
|
||||||
"version": "2.6.11",
|
|
||||||
"resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.11.tgz",
|
|
||||||
"integrity": "sha512-5wjnpaT/3dV+XB4borEsnAYQchn00XSgTAWKDkEqv+K8KevjbzmofK6hfJ9TZIlpj2N0xQpazy7PiRQiWHqzWg=="
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"aws-sign2": {
|
"aws-sign2": {
|
||||||
"version": "0.7.0",
|
"version": "0.7.0",
|
||||||
@ -6758,6 +6748,14 @@
|
|||||||
"resolved": "https://registry.npmjs.org/figgy-pudding/-/figgy-pudding-3.5.2.tgz",
|
"resolved": "https://registry.npmjs.org/figgy-pudding/-/figgy-pudding-3.5.2.tgz",
|
||||||
"integrity": "sha512-0btnI/H8f2pavGMN8w40mlSKOfTK2SVJmBfBeVIj3kNw0swwgzyRq0d5TJVOwodFmtvpPeWPN/MCcfuWF0Ezbw=="
|
"integrity": "sha512-0btnI/H8f2pavGMN8w40mlSKOfTK2SVJmBfBeVIj3kNw0swwgzyRq0d5TJVOwodFmtvpPeWPN/MCcfuWF0Ezbw=="
|
||||||
},
|
},
|
||||||
|
"file-selector": {
|
||||||
|
"version": "0.1.12",
|
||||||
|
"resolved": "https://registry.npmjs.org/file-selector/-/file-selector-0.1.12.tgz",
|
||||||
|
"integrity": "sha512-Kx7RTzxyQipHuiqyZGf+Nz4vY9R1XGxuQl/hLoJwq+J4avk/9wxxgZyHKtbyIPJmbD4A66DWGYfyykWNpcYutQ==",
|
||||||
|
"requires": {
|
||||||
|
"tslib": "^1.9.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"filename-regex": {
|
"filename-regex": {
|
||||||
"version": "2.0.1",
|
"version": "2.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/filename-regex/-/filename-regex-2.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/filename-regex/-/filename-regex-2.0.1.tgz",
|
||||||
@ -12737,12 +12735,33 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"react-dropzone": {
|
"react-dropzone": {
|
||||||
"version": "4.3.0",
|
"version": "11.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/react-dropzone/-/react-dropzone-4.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/react-dropzone/-/react-dropzone-11.0.1.tgz",
|
||||||
"integrity": "sha512-ULfrLaTSsd8BDa9KVAGCueuq1AN3L14dtMsGGqtP0UwYyjG4Vhf158f/ITSHuSPYkZXbvfcIiOlZsH+e3QWm+Q==",
|
"integrity": "sha512-x/6wqRHaR8jsrNiu/boVMIPYuoxb83Vyfv77hO7/3ZRn8Pr+KH5onsCsB8MLBa3zdJl410C5FXPUINbu16XIzw==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"attr-accept": "^1.1.3",
|
"attr-accept": "^2.0.0",
|
||||||
"prop-types": "^15.5.7"
|
"file-selector": "^0.1.12",
|
||||||
|
"prop-types": "^15.7.2"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"loose-envify": {
|
||||||
|
"version": "1.4.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz",
|
||||||
|
"integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==",
|
||||||
|
"requires": {
|
||||||
|
"js-tokens": "^3.0.0 || ^4.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"prop-types": {
|
||||||
|
"version": "15.7.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.7.2.tgz",
|
||||||
|
"integrity": "sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ==",
|
||||||
|
"requires": {
|
||||||
|
"loose-envify": "^1.4.0",
|
||||||
|
"object-assign": "^4.1.1",
|
||||||
|
"react-is": "^16.8.1"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"react-infinite-scroller": {
|
"react-infinite-scroller": {
|
||||||
|
@ -81,7 +81,7 @@
|
|||||||
"react-copy-to-clipboard": "^5.0.2",
|
"react-copy-to-clipboard": "^5.0.2",
|
||||||
"react-custom-scrollbars": "^4.2.1",
|
"react-custom-scrollbars": "^4.2.1",
|
||||||
"react-dom": "^16.13.1",
|
"react-dom": "^16.13.1",
|
||||||
"react-dropzone": "^4.3.0",
|
"react-dropzone": "^11.0.1",
|
||||||
"react-infinite-scroller": "^1.2.4",
|
"react-infinite-scroller": "^1.2.4",
|
||||||
"react-onclickout": "^2.0.8",
|
"react-onclickout": "^2.0.8",
|
||||||
"react-redux": "^5.1.2",
|
"react-redux": "^5.1.2",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user