コード例 #1
0
ファイル: files.go プロジェクト: intfrr/sendto
// NewFilePath sets a default path for this file.
func (m *File) NewFilePath(fh *multipart.FileHeader) error {
	m.Path = fmt.Sprintf("files/%d/%s", m.Id, file.SanitizeName(fh.Filename))
	params := map[string]string{"path": m.Path}
	return Query().Where("id=?", m.Id).Update(params)
}
コード例 #2
0
ファイル: images.go プロジェクト: BobbWu/fragmenta-cms
// NB this assumes that the path ends in .jpg
func (m *Image) SetDefaultOriginalPath() error {
	m.Path = fmt.Sprintf("files/images/%d/%s.jpg", m.Id, file.SanitizeName(m.Name))
	return m.Update(map[string]string{"path": m.Path})
}
コード例 #3
0
ファイル: stories.go プロジェクト: kennygrant/gohackernews
// CanonicalURL is the canonical URL of the story on this site
// including a slug for seo
func (m *Story) CanonicalURL() string {
	return fmt.Sprintf("/stories/%d-%s", m.Id, file.SanitizeName(m.Name))
}