You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

41 lines
1.3 KiB

  1. package storage
  2. import (
  3. "io"
  4. "time"
  5. )
  6. type Metadata struct {
  7. // ContentType is the original uploading content type
  8. ContentType string
  9. // ContentLength contains the length of the actual object
  10. ContentLength int64
  11. // Downloads is the actual number of downloads
  12. Downloads int
  13. // MaxDownloads contains the maximum numbers of downloads
  14. MaxDownloads int
  15. // MaxDate contains the max age of the file
  16. MaxDate time.Time
  17. // DeletionToken contains the token to match against for deletion
  18. DeletionToken string
  19. // Secret as knowledge to delete file
  20. Secret string
  21. }
  22. type Storage interface {
  23. // Get returns the entire file as io.ReadCloser and its metadata
  24. Get(token string, filename string) (reader io.ReadCloser, metaData Metadata, err error)
  25. // Head returns the metadata
  26. Head(token string, filename string) (metadata Metadata, err error)
  27. // Meta updates the file's metadata
  28. Meta(token string, filename string, metadata Metadata) error
  29. // Put stores the content of reader including the metadata
  30. Put(token string, filename string, reader io.Reader, metadata Metadata) error
  31. // Delete deletes the file
  32. Delete(token string, filename string) error
  33. // IsNotExist checks if the error is an "not file does not exist" error
  34. IsNotExist(err error) bool
  35. // Type returns the name of the storage it implements
  36. Type() string
  37. }