mirror of
https://github.com/eiblog/eiblog.git
synced 2026-02-08 07:42:27 +08:00
update
This commit is contained in:
4
api.go
4
api.go
@@ -430,7 +430,7 @@ func apiFileUpload(c *gin.Context) {
|
||||
}
|
||||
typ := c.Request.Header.Get("Content-Type")
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"name": filename,
|
||||
"title": filename,
|
||||
"isImage": typ[:5] == "image",
|
||||
"url": url,
|
||||
"bytes": fmt.Sprintf("%dkb", s.Size()/1000),
|
||||
@@ -445,7 +445,7 @@ func apiFileDelete(c *gin.Context) {
|
||||
}
|
||||
c.String(http.StatusOK, "删掉了吗?鬼知道。。。")
|
||||
}()
|
||||
name := c.PostForm("name")
|
||||
name := c.PostForm("title")
|
||||
if name == "" {
|
||||
err = errors.New("参数错误")
|
||||
return
|
||||
|
||||
3
qiniu.go
3
qiniu.go
@@ -9,6 +9,7 @@ import (
|
||||
"github.com/eiblog/eiblog/setting"
|
||||
"qiniupkg.com/api.v7/kodo"
|
||||
"qiniupkg.com/api.v7/kodocli"
|
||||
url "qiniupkg.com/x/url.v7"
|
||||
)
|
||||
|
||||
var qiniu_cfg = &kodo.Config{
|
||||
@@ -71,7 +72,7 @@ func FileUpload(name string, size int64, data io.Reader) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
|
||||
url := kodo.MakeBaseUrl(setting.Conf.Kodo.Domain, ret.Key)
|
||||
url := "https://" + setting.Conf.Kodo.Domain + "/" + url.Escape(key)
|
||||
return url, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -739,11 +739,11 @@ $(document).ready(function() {
|
||||
|
||||
var completeFile = null;
|
||||
function fileUploadComplete (id, data) {
|
||||
var li = $('#' + id).removeClass('loading').data('name', data.name)
|
||||
var li = $('#' + id).removeClass('loading').data('title', data.title)
|
||||
.data('url', data.url)
|
||||
.data('image', data.isImage)
|
||||
.html('<input type="hidden" name="attachment[]" value="' + data.cid + '" />'
|
||||
+ '<a class="insert" target="_blank" href="###" title="点击插入文件">' + data.name + '</a><div class="info">' + data.bytes
|
||||
.html('<input type="hidden" name="attachment[]" value="' + data.title + '" />'
|
||||
+ '<a class="insert" target="_blank" href="###" title="点击插入文件">' + data.title + '</a><div class="info">' + data.bytes
|
||||
+ ' <a class="file" target="_blank" href="'
|
||||
+ data.url + '" title="查看"><i class="i-edit"></i></a>'
|
||||
+ ' <a class="delete" href="###" title="删除"><i class="i-delete"></i></a></div>')
|
||||
@@ -763,11 +763,11 @@ $(document).ready(function() {
|
||||
browse_button : $('.upload-file').get(0),
|
||||
url : '/admin/api/file-upload',
|
||||
runtimes : 'html5,flash,html4',
|
||||
flash_swf_url : '/static/admin/js/Moxie.swf',
|
||||
flash_swf_url : '/static/admin/Moxie.swf',
|
||||
drop_element : $('.upload-area').get(0),
|
||||
filters : {
|
||||
max_file_size : '2mb',
|
||||
<!-- mime_types : [{'title' : '允许上传的文件', 'extensions' : 'gif,jpg,jpeg,png,tiff,bmp'}], -->
|
||||
// mime_types : [{'title' : '允许上传的文件', 'extensions' : 'gif,jpg,jpeg,png,tiff,bmp'}],
|
||||
prevent_duplicates : true
|
||||
},
|
||||
|
||||
@@ -824,9 +824,9 @@ $(document).ready(function() {
|
||||
var file = $('a.insert', el).text();
|
||||
$('.delete', el).click(function () {
|
||||
if (confirm('确认要删除文件 %s 吗?'.replace('%s', file))) {
|
||||
var name = $(this).parents('li').data('name');
|
||||
var title = $(this).parents('li').data('title');
|
||||
$.post('/admin/api/file-delete',
|
||||
{'name' : name},
|
||||
{'title' : title},
|
||||
function () {
|
||||
$(el).fadeOut(function () {
|
||||
$(this).remove();
|
||||
|
||||
Reference in New Issue
Block a user