func GetMessageAttachment(w http.ResponseWriter, req *http.Request) {
	haddr, err := hash.NewFromHash(mux.Vars(req)["addr"])
	if err != nil {
		httputils.ErrorOut(w, http.StatusNotFound, accountNotFound)
		return
	}

	messageID := mux.Vars(req)["message"]
	attachmentID := mux.Vars(req)["attachment"]

	ar := container.Instance.GetAccountRepo()
	attachment, size, err := ar.FetchMessageAttachment(*haddr, messageID, attachmentID)
	if err != nil {
		httputils.ErrorOut(w, http.StatusBadRequest, "incorrect attachment")
		return
	}

	// Copy data from our reader to http writer (buffered)
	w.Header().Set("Content-Type", "application/binary")
	w.WriteHeader(http.StatusOK)
	bw, err := io.Copy(w, attachment)
	if err != nil {
		logrus.Errorf("Could only write %d out of %d bytes from attachment %s/%s", bw, size, messageID, attachmentID)
	}
}
// GetMessageAttachment will return a message attachment
GetMessageAttachment will return a message attachment
// GetMessageAttachment will return a message attachment
func GetMessageAttachment(w http.ResponseWriter, req *http.Request) {
	haddr, err := hash.NewFromHash(mux.Vars(req)["addr"])
	if err != nil {
		httputils.ErrorOut(w, http.StatusNotFound, accountNotFound)
		return
	}
	messageID := mux.Vars(req)["message"]
	attachmentID := mux.Vars(req)["attachment"]
	ar := container.Instance.GetAccountRepo()
	attachment, size, err := ar.FetchMessageAttachment(*haddr, messageID, attachmentID)
	if err != nil {
		httputils.ErrorOut(w, http.StatusBadRequest, "incorrect attachment")
		return
	}
	w.Header().Set("Content-Type", "application/binary")
	w.WriteHeader(http.StatusOK)
	bw, err := io.Copy(w, attachment)
	if err != nil {
		logrus.Errorf("Could only write %d out of %d bytes from attachment %s/%s", bw, size, messageID, attachmentID)
	}
}
func GetMessageAttachment ( w http . ResponseWriter , req * http . Request ) { haddr , err := hash . NewFromHash ( mux . Vars ( req ) [ " " ] ) if err != nil { httputils . ErrorOut ( w , http . StatusNotFound , accountNotFound ) return } messageID := mux . Vars ( req ) [ " " ] attachmentID := mux . Vars ( req ) [ " " ] ar := container . Instance . GetAccountRepo ( ) attachment , size , err := ar . FetchMessageAttachment ( * haddr , messageID , attachmentID ) if err != nil { httputils . ErrorOut ( w , http . StatusBadRequest , " " ) return } w . Header ( ) . Set ( " " , " " ) w . WriteHeader ( http . StatusOK ) bw , err := io . Copy ( w , attachment ) if err != nil { logrus . Errorf ( " " , bw , size , messageID , attachmentID ) } }
GetMessageAttachment will return a message attachment
GetMessageAttachment will return a message attachment
// Copy data from our reader to http writer (buffered)