Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
-布谷鸟-
nosqlclient
提交
56d6b060
N
nosqlclient
项目概览
-布谷鸟-
/
nosqlclient
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
N
nosqlclient
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
56d6b060
编写于
5月 05, 2017
作者:
R
rsercano
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
almost done #352
上级
aae14c14
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
38 addition
and
37 deletion
+38
-37
client/imports/views/pages/file_management/file_management.js
...nt/imports/views/pages/file_management/file_management.js
+5
-5
client/imports/views/pages/file_management/upload_file/upload_file.js
...ts/views/pages/file_management/upload_file/upload_file.js
+1
-1
server/imports/internal/startup.js
server/imports/internal/startup.js
+3
-2
server/imports/mongodb/methods_collection.js
server/imports/mongodb/methods_collection.js
+3
-3
server/imports/mongodb/methods_common.js
server/imports/mongodb/methods_common.js
+0
-1
server/imports/mongodb/methods_gridfs.js
server/imports/mongodb/methods_gridfs.js
+17
-17
server/imports/webapp.js
server/imports/webapp.js
+9
-8
未找到文件。
client/imports/views/pages/file_management/file_management.js
浏览文件 @
56d6b060
...
...
@@ -53,7 +53,7 @@ export const initFilesInformation = function () {
return
;
}
Meteor
.
call
(
'
getFileInfos
'
,
$
(
'
#txtBucketName
'
).
val
(),
selector
,
$
(
'
#txtFileFetchLimit
'
).
val
(),
function
(
err
,
result
)
{
Meteor
.
call
(
'
getFileInfos
'
,
$
(
'
#txtBucketName
'
).
val
(),
selector
,
$
(
'
#txtFileFetchLimit
'
).
val
(),
Meteor
.
default_connection
.
_lastSessionId
,
function
(
err
,
result
)
{
if
(
err
||
result
.
error
)
{
Helper
.
showMeteorFuncError
(
err
,
result
,
"
Couldn't get file informations
"
);
return
;
...
...
@@ -142,7 +142,7 @@ Template.fileManagement.events({
return
;
}
Meteor
.
call
(
'
deleteFiles
'
,
$
(
'
#txtBucketName
'
).
val
(),
selector
,
Meteor
.
default_connection
.
_lastSessionId
,
function
(
err
,
result
)
{
Meteor
.
call
(
'
deleteFiles
'
,
$
(
'
#txtBucketName
'
).
val
(),
selector
,
Meteor
.
default_connection
.
_lastSessionId
,
function
(
err
,
result
)
{
if
(
err
||
result
.
err
)
{
Helper
.
showMeteorFuncError
(
err
,
result
,
"
Couldn't delete files
"
);
}
else
{
...
...
@@ -163,7 +163,7 @@ Template.fileManagement.events({
e
.
preventDefault
();
const
fileRow
=
Session
.
get
(
Helper
.
strSessionSelectedFile
);
if
(
fileRow
)
{
window
.
open
(
'
download?fileId=
'
+
fileRow
.
_id
+
'
&bucketName=
'
+
$
(
'
#txtBucketName
'
).
val
());
window
.
open
(
'
download?fileId=
'
+
fileRow
.
_id
+
'
&bucketName=
'
+
$
(
'
#txtBucketName
'
).
val
()
+
'
&sessionId=
'
+
Meteor
.
default_connection
.
_lastSessionId
);
}
},
...
...
@@ -183,7 +183,7 @@ Template.fileManagement.events({
if
(
isConfirm
)
{
Ladda
.
create
(
document
.
querySelector
(
'
#btnReloadFiles
'
)).
start
();
Meteor
.
call
(
'
deleteFile
'
,
$
(
'
#txtBucketName
'
).
val
(),
fileRow
.
_id
,
function
(
err
)
{
Meteor
.
call
(
'
deleteFile
'
,
$
(
'
#txtBucketName
'
).
val
(),
fileRow
.
_id
,
Meteor
.
default_connection
.
_lastSessionId
,
function
(
err
)
{
if
(
err
)
{
toastr
.
error
(
"
Couldn't delete:
"
+
err
.
message
);
}
else
{
...
...
@@ -216,7 +216,7 @@ Template.fileManagement.events({
delete
setValue
.
_id
;
Meteor
.
call
(
'
updateOne
'
,
$
(
'
#txtBucketName
'
).
val
()
+
'
.files
'
,
{
'
_id
'
:
{
"
$oid
"
:
Session
.
get
(
Helper
.
strSessionSelectedFile
).
_id
}},
{
"
$set
"
:
setValue
},
{},
Meteor
.
default_connection
.
_lastSessionId
,
function
(
err
)
{
{
'
_id
'
:
{
"
$oid
"
:
Session
.
get
(
Helper
.
strSessionSelectedFile
).
_id
}},
{
"
$set
"
:
setValue
},
{},
Meteor
.
default_connection
.
_lastSessionId
,
function
(
err
)
{
if
(
err
)
{
toastr
.
error
(
"
Couldn't update file info:
"
+
err
.
message
);
}
else
{
...
...
client/imports/views/pages/file_management/upload_file/upload_file.js
浏览文件 @
56d6b060
...
...
@@ -53,7 +53,7 @@ export const proceedUploading = function (blob, contentType, metaData, aliases)
Ladda
.
create
(
document
.
querySelector
(
'
#btnUpload
'
)).
start
();
const
fileReader
=
new
FileReader
();
fileReader
.
onload
=
function
(
file
)
{
Meteor
.
call
(
'
uploadFile
'
,
$
(
'
#txtBucketName
'
).
val
(),
new
Uint8Array
(
file
.
target
.
result
),
blob
.
name
,
contentType
,
metaData
,
aliases
,
function
(
err
,
result
)
{
Meteor
.
call
(
'
uploadFile
'
,
$
(
'
#txtBucketName
'
).
val
(),
new
Uint8Array
(
file
.
target
.
result
),
blob
.
name
,
contentType
,
metaData
,
aliases
,
Meteor
.
default_connection
.
_lastSessionId
,
function
(
err
,
result
)
{
if
(
err
||
result
.
error
)
{
Helper
.
showMeteorFuncError
(
err
,
result
,
"
Couldn't upload file
"
);
}
...
...
server/imports/internal/startup.js
浏览文件 @
56d6b060
...
...
@@ -96,6 +96,7 @@ const migrateSSHPart = function (oldConnection, connection) {
host
:
oldConnection
.
sshAddress
,
port
:
oldConnection
.
sshPort
,
username
:
oldConnection
.
sshUser
,
destinationPort
:
oldConnection
.
sshPort
};
if
(
oldConnection
.
sshPassword
)
connection
.
ssh
.
password
=
oldConnection
.
sshPassword
;
...
...
@@ -117,7 +118,7 @@ function tryInjectDefaultConnection() {
connection
.
connectionName
=
DEFAULT_CONNECTION_NAME
;
// delete existing connection after we parsed the new one
let
existingConnection
=
Connections
.
findOne
({
connectionName
:
DEFAULT_CONNECTION_NAME
});
let
existingConnection
=
Connections
.
findOne
({
connectionName
:
DEFAULT_CONNECTION_NAME
});
if
(
existingConnection
)
{
Connections
.
remove
(
existingConnection
.
_id
);
connection
.
_id
=
existingConnection
.
_id
;
...
...
@@ -155,5 +156,5 @@ Meteor.startup(function () {
ShellCommands
.
remove
({});
SchemaAnalyzeResult
.
remove
({});
migrateConnectionsIfExist
();
tryInjectDefaultConnection
();
tryInjectDefaultConnection
();
});
server/imports/mongodb/methods_collection.js
浏览文件 @
56d6b060
...
...
@@ -21,7 +21,7 @@ const proceedMapReduceExecution = function (selectedCollection, map, reduce, opt
done
(
err
,
null
);
return
;
}
if
((
typeof
options
.
out
)
==
'
string
'
)
{
if
((
typeof
options
.
out
)
==
=
'
string
'
)
{
resultCollection
.
find
().
toArray
(
function
(
err
,
result
)
{
done
(
err
,
result
);
});
...
...
@@ -47,12 +47,12 @@ export const proceedQueryExecution = function (selectedCollection, methodArray,
try
{
let
execution
=
databasesBySessionId
[
sessionId
].
collection
(
selectedCollection
);
for
(
let
i
=
0
;
i
<
methodArray
.
length
;
i
++
)
{
let
last
=
i
==
(
methodArray
.
length
-
1
);
let
last
=
(
i
===
(
methodArray
.
length
-
1
)
);
let
entry
=
methodArray
[
i
];
entry
=
Helper
.
convertJSONtoBSON
(
entry
);
for
(
let
key
in
entry
)
{
if
(
entry
.
hasOwnProperty
(
key
))
{
if
(
last
&&
key
==
Object
.
keys
(
entry
)[
Object
.
keys
(
entry
).
length
-
1
])
{
if
(
last
&&
key
==
=
Object
.
keys
(
entry
)[
Object
.
keys
(
entry
).
length
-
1
])
{
entry
[
key
].
push
(
function
(
err
,
docs
)
{
done
(
err
,
docs
);
});
...
...
server/imports/mongodb/methods_common.js
浏览文件 @
56d6b060
...
...
@@ -22,7 +22,6 @@ export let databasesBySessionId = {};
let
spawnedShellsBySessionId
=
{};
let
tunnelsBySessionId
=
{};
export
let
database
;
let
spawnedShell
;
let
tunnel
;
...
...
server/imports/mongodb/methods_gridfs.js
浏览文件 @
56d6b060
...
...
@@ -4,21 +4,21 @@
/*global Async*/
import
LOGGER
from
"
../internal/logger
"
;
import
Helper
from
"
./helper
"
;
import
{
database
}
from
"
./methods_common
"
;
import
{
database
sBySessionId
}
from
"
./methods_common
"
;
import
{
Meteor
}
from
"
meteor/meteor
"
;
const
mongodbApi
=
require
(
'
mongodb
'
);
Meteor
.
methods
({
deleteFiles
(
bucketName
,
selector
){
LOGGER
.
info
(
'
[deleteFiles]
'
,
bucketName
,
selector
);
deleteFiles
(
bucketName
,
selector
,
sessionId
){
LOGGER
.
info
(
'
[deleteFiles]
'
,
bucketName
,
selector
,
sessionId
);
selector
=
Helper
.
convertJSONtoBSON
(
selector
);
let
result
=
Async
.
runSync
(
function
(
done
)
{
try
{
let
filesCollection
=
database
.
collection
(
bucketName
+
"
.files
"
);
let
chunksCollection
=
database
.
collection
(
bucketName
+
"
.chunks
"
);
let
filesCollection
=
database
sBySessionId
[
sessionId
]
.
collection
(
bucketName
+
"
.files
"
);
let
chunksCollection
=
database
sBySessionId
[
sessionId
]
.
collection
(
bucketName
+
"
.chunks
"
);
filesCollection
.
find
(
selector
,
{
_id
:
1
}).
toArray
(
function
(
err
,
docs
)
{
if
(
err
)
{
...
...
@@ -54,12 +54,12 @@ Meteor.methods({
return
Helper
.
convertBSONtoJSON
(
result
);
},
deleteFile
(
bucketName
,
fileId
)
{
LOGGER
.
info
(
'
[deleteFile]
'
,
bucketName
,
fileId
);
deleteFile
(
bucketName
,
fileId
,
sessionId
)
{
LOGGER
.
info
(
'
[deleteFile]
'
,
bucketName
,
fileId
,
sessionId
);
let
result
=
Async
.
runSync
(
function
(
done
)
{
try
{
const
bucket
=
new
mongodbApi
.
GridFSBucket
(
database
,
{
bucketName
:
bucketName
});
const
bucket
=
new
mongodbApi
.
GridFSBucket
(
database
sBySessionId
[
sessionId
]
,
{
bucketName
:
bucketName
});
bucket
.
delete
(
new
mongodbApi
.
ObjectId
(
fileId
),
function
(
err
)
{
done
(
err
,
null
);
});
...
...
@@ -73,16 +73,16 @@ Meteor.methods({
return
Helper
.
convertBSONtoJSON
(
result
);
},
getFileInfos
(
bucketName
,
selector
,
limit
)
{
getFileInfos
(
bucketName
,
selector
,
limit
,
sessionId
)
{
limit
=
parseInt
(
limit
)
||
100
;
selector
=
selector
||
{};
selector
=
Helper
.
convertJSONtoBSON
(
selector
);
LOGGER
.
info
(
'
[getFileInfos]
'
,
bucketName
,
JSON
.
stringify
(
selector
),
limit
);
LOGGER
.
info
(
'
[getFileInfos]
'
,
bucketName
,
JSON
.
stringify
(
selector
),
limit
,
sessionId
);
let
result
=
Async
.
runSync
(
function
(
done
)
{
try
{
const
bucket
=
new
mongodbApi
.
GridFSBucket
(
database
,
{
bucketName
:
bucketName
});
const
bucket
=
new
mongodbApi
.
GridFSBucket
(
database
sBySessionId
[
sessionId
]
,
{
bucketName
:
bucketName
});
bucket
.
find
(
selector
,
{
limit
:
limit
}).
toArray
(
function
(
err
,
files
)
{
done
(
err
,
files
);
});
...
...
@@ -97,18 +97,18 @@ Meteor.methods({
return
Helper
.
convertBSONtoJSON
(
result
);
},
uploadFile
(
bucketName
,
blob
,
fileName
,
contentType
,
metaData
,
aliases
)
{
uploadFile
(
bucketName
,
blob
,
fileName
,
contentType
,
metaData
,
aliases
,
sessionId
)
{
if
(
metaData
)
{
metaData
=
Helper
.
convertJSONtoBSON
(
metaData
);
}
blob
=
new
Buffer
(
blob
);
LOGGER
.
info
(
'
[uploadFile]
'
,
bucketName
,
fileName
,
contentType
,
JSON
.
stringify
(
metaData
),
aliases
);
LOGGER
.
info
(
'
[uploadFile]
'
,
bucketName
,
fileName
,
contentType
,
JSON
.
stringify
(
metaData
),
aliases
,
sessionId
);
return
Async
.
runSync
(
function
(
done
)
{
try
{
const
bucket
=
new
mongodbApi
.
GridFSBucket
(
database
,
{
bucketName
:
bucketName
});
const
bucket
=
new
mongodbApi
.
GridFSBucket
(
database
sBySessionId
[
sessionId
]
,
{
bucketName
:
bucketName
});
let
uploadStream
=
bucket
.
openUploadStream
(
fileName
,
{
metadata
:
metaData
,
contentType
:
contentType
,
...
...
@@ -126,12 +126,12 @@ Meteor.methods({
});
},
getFile
(
bucketName
,
fileId
)
{
LOGGER
.
info
(
'
[getFile]
'
,
bucketName
,
fileId
);
getFile
(
bucketName
,
fileId
,
sessionId
)
{
LOGGER
.
info
(
'
[getFile]
'
,
bucketName
,
fileId
,
sessionId
);
let
result
=
Async
.
runSync
(
function
(
done
)
{
try
{
let
filesCollection
=
database
.
collection
(
bucketName
+
'
.files
'
);
let
filesCollection
=
database
sBySessionId
[
sessionId
]
.
collection
(
bucketName
+
'
.files
'
);
filesCollection
.
find
({
_id
:
new
mongodbApi
.
ObjectId
(
fileId
)}).
limit
(
1
).
next
(
function
(
err
,
doc
)
{
if
(
doc
)
{
done
(
null
,
doc
);
...
...
server/imports/webapp.js
浏览文件 @
56d6b060
/**
* Created by Sercan on 26.10.2016.
*/
import
{
WebApp
}
from
'
meteor/webapp
'
;
import
{
Meteor
}
from
'
meteor/meteor
'
;
import
{
Papa
}
from
'
meteor/harrison:papa-parse
'
;
import
{
database
}
from
"
/server/imports/mongodb/methods_common
"
;
import
{
WebApp
}
from
"
meteor/webapp
"
;
import
{
Meteor
}
from
"
meteor/meteor
"
;
import
{
Papa
}
from
"
meteor/harrison:papa-parse
"
;
import
{
database
sBySessionId
}
from
"
/server/imports/mongodb/methods_common
"
;
import
LOGGER
from
"
/server/imports/internal/logger
"
;
const
mongodbApi
=
require
(
'
mongodb
'
);
...
...
@@ -18,7 +18,7 @@ WebApp.connectHandlers.use('/export', function (req, res) {
LOGGER
.
info
(
'
[export]
'
,
format
,
selectedCollection
,
selector
,
cursorOptions
);
Meteor
.
call
(
"
find
"
,
selectedCollection
,
JSON
.
parse
(
selector
),
JSON
.
parse
(
cursorOptions
),
false
,
Meteor
.
default_connection
.
_lastSessionId
,
function
(
err
,
result
)
{
Meteor
.
call
(
"
find
"
,
selectedCollection
,
JSON
.
parse
(
selector
),
JSON
.
parse
(
cursorOptions
),
false
,
Meteor
.
default_connection
.
_lastSessionId
,
function
(
err
,
result
)
{
if
(
err
||
result
.
error
)
{
LOGGER
.
error
(
'
[export]
'
,
err
,
result
.
error
);
res
.
writeHead
(
400
);
...
...
@@ -52,8 +52,9 @@ WebApp.connectHandlers.use("/download", function (req, res) {
const
urlParts
=
decodeURI
(
req
.
url
).
split
(
'
&
'
);
let
fileId
=
urlParts
[
0
].
substr
(
urlParts
[
0
].
indexOf
(
'
=
'
)
+
1
);
let
bucketName
=
urlParts
[
1
].
substr
(
urlParts
[
1
].
indexOf
(
'
=
'
)
+
1
);
let
sessionId
=
urlParts
[
2
].
substr
(
urlParts
[
2
].
indexOf
(
'
=
'
)
+
1
);
LOGGER
.
info
(
'
[downloadFile]
'
,
fileId
,
bucketName
);
LOGGER
.
info
(
'
[downloadFile]
'
,
fileId
,
bucketName
,
sessionId
);
if
(
!
bucketName
||
!
fileId
)
{
LOGGER
.
info
(
'
[downloadFile]
'
,
'
file not found !
'
);
...
...
@@ -63,10 +64,10 @@ WebApp.connectHandlers.use("/download", function (req, res) {
}
try
{
let
filesCollection
=
database
.
collection
(
bucketName
+
'
.files
'
);
let
filesCollection
=
database
sBySessionId
[
sessionId
]
.
collection
(
bucketName
+
'
.files
'
);
filesCollection
.
find
({
_id
:
new
mongodbApi
.
ObjectId
(
fileId
)}).
limit
(
1
).
next
(
function
(
err
,
doc
)
{
if
(
doc
)
{
const
bucket
=
new
mongodbApi
.
GridFSBucket
(
database
,
{
bucketName
:
bucketName
});
const
bucket
=
new
mongodbApi
.
GridFSBucket
(
database
sBySessionId
[
sessionId
]
,
{
bucketName
:
bucketName
});
const
headers
=
{
'
Content-type
'
:
'
application/octet-stream
'
,
'
Content-Disposition
'
:
'
attachment; filename=
'
+
doc
.
filename
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录