mirror of
				https://github.com/mickael-kerjean/filestash.git
				synced 2025-11-04 05:27:04 +08:00 
			
		
		
		
	fix (cloudflare): cloudflare cache issue
This commit is contained in:
		@ -409,6 +409,11 @@ func FileAccess(ctx *App, res http.ResponseWriter, req *http.Request) {
 | 
				
			|||||||
var chunkedUploadCache AppCache
 | 
					var chunkedUploadCache AppCache
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func FileSave(ctx *App, res http.ResponseWriter, req *http.Request) {
 | 
					func FileSave(ctx *App, res http.ResponseWriter, req *http.Request) {
 | 
				
			||||||
 | 
						h := res.Header()
 | 
				
			||||||
 | 
						h.Set("Cache-Control", "no-store")
 | 
				
			||||||
 | 
						h.Set("Pragma", "no-cache")
 | 
				
			||||||
 | 
						h.Set("Connection", "Close")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	path, err := PathBuilder(ctx, req.URL.Query().Get("path"))
 | 
						path, err := PathBuilder(ctx, req.URL.Query().Get("path"))
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		Log.Debug("save::path '%s'", err.Error())
 | 
							Log.Debug("save::path '%s'", err.Error())
 | 
				
			||||||
@ -465,7 +470,6 @@ func FileSave(ctx *App, res http.ResponseWriter, req *http.Request) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	// - case2: chunked upload which implements the TUS protocol:
 | 
						// - case2: chunked upload which implements the TUS protocol:
 | 
				
			||||||
	//   https://www.ietf.org/archive/id/draft-tus-httpbis-resumable-uploads-protocol-00.html
 | 
						//   https://www.ietf.org/archive/id/draft-tus-httpbis-resumable-uploads-protocol-00.html
 | 
				
			||||||
	h := res.Header()
 | 
					 | 
				
			||||||
	ctx.Session["path"] = path
 | 
						ctx.Session["path"] = path
 | 
				
			||||||
	if proto == "tus" && req.Method == http.MethodPost {
 | 
						if proto == "tus" && req.Method == http.MethodPost {
 | 
				
			||||||
		if c := chunkedUploadCache.Get(ctx.Session); c != nil {
 | 
							if c := chunkedUploadCache.Get(ctx.Session); c != nil {
 | 
				
			||||||
@ -496,7 +500,6 @@ func FileSave(ctx *App, res http.ResponseWriter, req *http.Request) {
 | 
				
			|||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if proto == "tus" && req.Method == http.MethodPatch {
 | 
						if proto == "tus" && req.Method == http.MethodPatch {
 | 
				
			||||||
		h.Set("Connection", "Close")
 | 
					 | 
				
			||||||
		requestOffset, err := strconv.ParseUint(req.Header.Get("Upload-Offset"), 10, 0)
 | 
							requestOffset, err := strconv.ParseUint(req.Header.Get("Upload-Offset"), 10, 0)
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			SendErrorResult(res, ErrNotValid)
 | 
								SendErrorResult(res, ErrNotValid)
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user