Exemple #1
0
// test stat
func TestStat(t *testing.T) {
	DataInfo, err := backends.Stat("testfile")
	if err != nil {
		t.Error("Failed to STAT file - ", err)
	}
	if DataInfo.Size != 8 {
		t.Errorf("Failed to STAT file - incorrect size: %d", DataInfo.Size)
	}
}
Exemple #2
0
// getHead returns info pertaining to data corresponding to specified key
func getHead(rw http.ResponseWriter, req *http.Request) {

	// get data information
	fi, err := backends.Stat(req.URL.Query().Get(":blob"))
	if err != nil {
		rw.WriteHeader(404)
		rw.Write([]byte(fmt.Sprintf("%s\n", err.Error())))
		return
	}

	// set useful headers
	rw.Header().Set("Content-Length", fmt.Sprintf("%d", fi.Size))
	rw.Header().Set("Last-Modified", fi.ModTime.Format(time.RFC1123))
	rw.Header().Set("Date", time.Now().UTC().Format(time.RFC1123))

	//
	rw.Write(nil)
}