This repository has been archived by the owner on May 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
storage.go
69 lines (66 loc) · 2.37 KB
/
storage.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package sharexhandler
import (
"time"
"io"
)
type Entry interface {
// >>> Getter and setter methods
// There is no SetId method because the id will be generated by the Storage
// Returns a unique Id of the Entry
GetId() string
// Returns the author (access token)
GetAuthor() string
// Sets the author (access token)
SetAuthor(author string)
// Returns the filename
GetFilename() string
// Sets the filename
SetFilename(filename string)
// Returns the content type
GetContentType() string
// Sets the content type
SetContentType(contentType string)
// Returns the last modified date
GetLastModifiedValue() time.Time
// Sets the e-tag value
SetLastModifiedValue(lastModified time.Time)
// Returns the upload date
GetUploadDate() time.Time
// Sets the upload date
SetUploadDate(uploadDate time.Time)
// <<<
//
// >>> Storage methods
// This method is used to initially save the storages object.
// It sets the Id of the Entry.
// Returns an error if something went wrong or nil if not.
Save() error
// This method is used to update the storages object.
// It updates all fields.
// Returns an error if something went wrong or nil if not.
Update() error
// This method is used to delete the storages object
// It deletes the entry by its Id. Therefore only the Id has to be set.
// Returns an error if something went wrong or nil if not.
Delete() error
// This method is used to get a read-seeker and therefore the content of the entry.
// It returns a reader which can be used to read the data and an error if something went wrong or nil if not.
GetReadSeeker() (io.ReadSeeker, error)
// This method is used to store content of the file. It returns a writer which can be used to write all content.
GetWriter() (io.WriteCloser, error)
// <<<
}
// This interface is used to store/update/delete given files
type Storage interface {
// Initializes the connection/files to/of the storages
// Returns nil if the initialization was a success or a given error
Initialize() (error)
// Closes an existing connection/streams of the storages
// Returns whether the close process was a success and error or nil
Close() (bool, error)
// Returns the pointer to completely fresh and new instance of a Entry which is not stored yet
// To store it you should set the values and after that call the Save method.
NewStorageEntry() Entry
//
LoadStorageEntry(id string) (bool, error, Entry)
}