master
kgdxpr 4 years ago
parent f14dd5083d
commit aa09bc7ffc

@ -3,12 +3,7 @@
<component name="ChangeListManager">
<list default="true" id="0d4ad043-ffc9-484f-90ab-0d2e603f76d4" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Business/MinIORelate/MinIORelateController/MinIORelateController.go" beforeDir="false" afterPath="$PROJECT_DIR$/Business/MinIORelate/MinIORelateController/MinIORelateController.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Utils/DbUtil/DbUtil.go" beforeDir="false" afterPath="$PROJECT_DIR$/Utils/DbUtil/DbUtil.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/build/debug.sh" beforeDir="false" afterPath="$PROJECT_DIR$/build/debug.sh" afterDir="false" />
<change beforePath="$PROJECT_DIR$/build/dsCommonTools" beforeDir="false" afterPath="$PROJECT_DIR$/build/dsCommonTools" afterDir="false" />
<change beforePath="$PROJECT_DIR$/build/start.sh" beforeDir="false" afterPath="$PROJECT_DIR$/build/start.sh" afterDir="false" />
<change beforePath="$PROJECT_DIR$/build/stop.sh" beforeDir="false" afterPath="$PROJECT_DIR$/build/stop.sh" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Utils/SftpUtil/SftpUtil.go" beforeDir="false" afterPath="$PROJECT_DIR$/Utils/SftpUtil/SftpUtil.go" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -43,7 +38,7 @@
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="go.import.settings.migrated" value="true" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/Utils" />
<property name="last_opened_file_path" value="H:/Go_Test/Test03" />
</component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
@ -120,6 +115,11 @@
<line>2</line>
<option name="timeStamp" value="2" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/Utils/ConfigUtil/ConfigUtil.go</url>
<line>126</line>
<option name="timeStamp" value="3" />
</line-breakpoint>
</breakpoints>
</breakpoint-manager>
</component>

@ -50,7 +50,6 @@ func UploadFile(sftpClient *sftp.Client, localFilePath string, remotePath string
if err != nil {
fmt.Println("os.Open error : ", localFilePath)
log.Fatal(err)
}
defer srcFile.Close()
//golang中path.Base(pathString)函数,pathString的值必须为 linux 风格的路径,即 "/" 才能够正常的获取最后的路径段的值。
@ -87,7 +86,7 @@ func UploadDirectory(sftpClient *sftp.Client, localPath string, remotePath strin
sftpClient.Mkdir(remoteFilePath)
UploadDirectory(sftpClient, localFilePath, remoteFilePath)
} else {
UploadFile(sftpClient, path.Join(localPath, backupDir.Name()), remotePath)
UploadFile(sftpClient, path.Join(localPath, backupDir.Name()), remotePath)
}
}

@ -0,0 +1,93 @@
<!DOCTYPE html>
<html>
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type" />
<meta content="utf-8" http-equiv="encoding" />
<script src="http://code.jquery.com/jquery-1.9.1.min.js">
</script>
<title>
前台上传文件
</title>
<script type="text/javascript">
var id;
function postData() {
//获取文件名
var filename = getFileName($("#uploadfile").val());
$.ajax({    
url: '/tools/minioRelate/getPostPolicyInfo?filename=' + filename, //获取上传文件时用到的相关信息
    type: 'GET',
    async: false,
    success: function(res) {
if (res.success) {
var formData = new FormData();
formData.append("file", $("#uploadfile")[0].files[0]);
formData.append("policy", res.policy);
formData.append("x-amz-algorithm", res.x_amz_algorithm);
formData.append("x-amz-credential", res.x_amz_credential);
formData.append("x-amz-date", res.x_amz_date);
formData.append("x-amz-signature", res.x_amz_signature);
formData.append("bucket", res.bucket);
formData.append("key", res.key);
id = res.id
//正式上传文件
$.ajax({
url: res.url,
type: 'POST',
async: false,
data: formData,
contentType: false,
processData: false,
mimeType: 'multipart/form-data',
success: function() {
//上传成功后调用接口,后台将上传文件的相关信息进行记录
$.ajax({    
url: '/tools/minioRelate/saveFileInfo?id=' + id + "&systemid=gl",
    type: 'GET',
    async: false,
    success: function() {
alert("上传成功!");
}
});
}
});
} else {
alert(res.info);
}     
}
});
}
//获取预览地址
function preview()
{
$.ajax({    
url: '/tools/minioRelate/generatePreviewUrl?id=' + id,
    type: 'GET',
    async: false,
    success: function(res) {
$("#preview").attr('src', res.url);
}
});
}
//获取文件名
function getFileName(o) {
var pos = o.lastIndexOf("\\");
return o.substring(pos + 1);
}
</script>
</head>
<body>
<input type="file" name="uploadfile" id="uploadfile" value="" />
<input type="button" onclick="postData();" value="上传" name="" />
<input type="button" onclick="preview();" value="查看刚上传文件的预览" name="" />
<br />
<iframe id="preview" width="800" height="600"></iframe>
</body>
</html>
Loading…
Cancel
Save