Documentation
¶
Index ¶
- Constants
- Variables
- type NimbusHTTP
- type NimbusHTTPFormImpl
- func (n *NimbusHTTPFormImpl) Cleanup()
- func (n *NimbusHTTPFormImpl) Delete(w http.ResponseWriter, r *http.Request)
- func (n *NimbusHTTPFormImpl) Download(w http.ResponseWriter, r *http.Request)
- func (n *NimbusHTTPFormImpl) DownloadMany(w http.ResponseWriter, r *http.Request)
- func (n *NimbusHTTPFormImpl) Upload(w http.ResponseWriter, r *http.Request)
- func (n *NimbusHTTPFormImpl) UploadMany(w http.ResponseWriter, _ *http.Request)
- type Zipper
Constants ¶
const ( DefaultTransferBuffSize = 256 Mb10 = (10 << 20) )
Variables ¶
var ( // Set of extension indicating that all extensions should be allowed. ExtAll = []string{"_all_"} // Set of image extensions which are most commonly used on the web. // From: developer.mozilla.org/en-US/docs/Web/Media/Formats/Image_types ExtImg = []string{ ".apng", ".avif", ".gif", ".jpg", ".jpeg", ".jfif", ".pjpeg", ".pjp", ".png", ".svg", ".webp", ".bmp", } // Set of extensions only allowing compressed files ExtComp = []string{".zip", ".tar", ".tgz", ".gz", ".bz2"} // Set of extensions only allowing text files ExtTxt = []string{".txt"} )
Extension sets
Functions ¶
This section is empty.
Types ¶
type NimbusHTTP ¶
type NimbusHTTP interface { Upload(w http.ResponseWriter, r *http.Request) UploadMany(w http.ResponseWriter, r *http.Request) Download(w http.ResponseWriter, r *http.Request) DownloadMany(w http.ResponseWriter, r *http.Request) Delete(w http.ResponseWriter, r *http.Request) Cleanup() }
NimbusHTTP defines the HTTP interface for the Nimbus file server.
func NewHTTPFormImpl ¶
func NewHTTPFormImpl(dfk string, maxSize, buffSize int64, tmpDir string, exts []string, allowNoExt bool) (NimbusHTTP, error)
NNewHTTPFormImpl creates and returns the form implementation of NimbusHTTP. The `dfk` argument is the "default file key" which is a string indicating the name of the file field in requests to be received. `maxSize` specifies the maximum supported file size and `buffSize` indicates the copy buffer size. `tmpDir` is the directory in which the uploaded files will be stored as temporary files. `exts` is a slice containing the extensions which should be permitted. `allowNoExt` specifies whether files without extensions should be handled.
type NimbusHTTPFormImpl ¶
type NimbusHTTPFormImpl struct {
// contains filtered or unexported fields
}
NimbusHTTPFormImpl is a NimbusHTTP implementation which handles file uploads performed using HTML forms or the FormData web API.
func (*NimbusHTTPFormImpl) Cleanup ¶
func (n *NimbusHTTPFormImpl) Cleanup()
func (*NimbusHTTPFormImpl) Delete ¶
func (n *NimbusHTTPFormImpl) Delete(w http.ResponseWriter, r *http.Request)
func (*NimbusHTTPFormImpl) Download ¶
func (n *NimbusHTTPFormImpl) Download(w http.ResponseWriter, r *http.Request)
Download defines the endpoint which writes the first requested file from the request queries under the specified "default file key" to the user.
func (*NimbusHTTPFormImpl) DownloadMany ¶
func (n *NimbusHTTPFormImpl) DownloadMany(w http.ResponseWriter, r *http.Request)
DownloadMany decodes a JSON body from the response with a string[] in the `filenames` field which specifies which files to archive and download. A zip archive is returned when all specified files exist and the archiving process does not encounter any errors. Otherwise, the encountered error is reported.
func (*NimbusHTTPFormImpl) Upload ¶
func (n *NimbusHTTPFormImpl) Upload(w http.ResponseWriter, r *http.Request)
Upload defines the endpoint which performs the download to the server. A single file is expected, with the form It is assumed that files will contain extensions and that the extension is the part of the filename from the last '.' to the end of the filename. This substring is required to be non-empty.
func (*NimbusHTTPFormImpl) UploadMany ¶
func (n *NimbusHTTPFormImpl) UploadMany(w http.ResponseWriter, _ *http.Request)