diff --git a/api.go b/api.go index e754f24..3728cdb 100644 --- a/api.go +++ b/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 diff --git a/qiniu.go b/qiniu.go index 90a2f53..ae428c8 100644 --- a/qiniu.go +++ b/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 } diff --git a/views/admin/post.html b/views/admin/post.html index 4991f93..10dc35a 100644 --- a/views/admin/post.html +++ b/views/admin/post.html @@ -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('' - + '' + data.name + '
' + data.bytes + .html('' + + '' + data.title + '
' + data.bytes + ' ' + '
') @@ -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'}], 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();