// GET /export?site=site-id?mode=file|stream
// exports all comments for siteID as json stream or gz file
GET /export?site=site-id?mode=file|stream
exports all comments for siteID as json stream or gz file
// GET / export?site = site - id?mode = file|stream // exports all comments for siteID as json stream or gz file
func (a *admin) exportCtrl(w http.ResponseWriter, r *http.Request) {
	siteID := r.URL.Query().Get("site")
	var writer io.Writer = w
	if r.URL.Query().Get("mode") == "file" {
		exportFile := fmt.Sprintf("%s-%s.json.gz", siteID, time.Now().Format("20060102"))
		w.Header().Set("Content-Type", "application/gzip")
		w.Header().Set("Content-Disposition", "attachment;filename="+exportFile)
		w.WriteHeader(http.StatusOK)
		gzWriter := gzip.NewWriter(w)
		defer func() {
			if e := gzWriter.Close(); e != nil {
				log.Printf("[WARN] can't close gzip writer, %s", e)
			}
		}()
		writer = gzWriter
	}
	if _, err := a.exporter.Export(writer, siteID); err != nil {
		rest.SendErrorJSON(w, r, http.StatusInternalServerError, err, "export failed")
		return
	}
}
func ( a * admin ) exportCtrl ( w http . ResponseWriter , r * http . Request ) { siteID := r . URL . Query ( ) . Get ( " " ) var writer io . Writer = w if r . URL . Query ( ) . Get ( " " ) == " " { exportFile := fmt . Sprintf ( " " , siteID , time . Now ( ) . Format ( " " ) ) w . Header ( ) . Set ( " " , " " ) w . Header ( ) . Set ( " " , " " + exportFile ) w . WriteHeader ( http . StatusOK ) gzWriter := gzip . NewWriter ( w ) defer func ( ) { if e := gzWriter . Close ( ) ; e != nil { log . Printf ( " " , e ) } } ( ) writer = gzWriter } if _ , err := a . exporter . Export ( writer , siteID ) ; err != nil { rest . SendErrorJSON ( w , r , http . StatusInternalServerError , err , " " ) return } }
GET /export?site=site-id?mode=file|stream
exports all comments for siteID as json stream or gz file
GET / export?site = site - id?mode = file|stream exports all comments for siteID as json stream or gz file