forked from yii2tech/file-storage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBucketInterface.php
158 lines (139 loc) · 4.79 KB
/
BucketInterface.php
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<?php
/**
* @link https://github.com/yii2tech
* @copyright Copyright (c) 2015 Yii2tech
* @license [New BSD License](http://www.opensource.org/licenses/bsd-license.php)
*/
namespace yii2tech\filestorage;
/**
* BucketInterface is an interface for the all file storage buckets.
* All buckets should be controlled by the instance of [[StorageInterface]].
*
* @see StorageInterface
*
* @author Paul Klimov <[email protected]>
* @since 1.0
*/
interface BucketInterface
{
/**
* Sets bucket name.
* @param string $name - bucket name.
* @return boolean success.
*/
public function setName($name);
/**
* Gets current bucket name.
* @return string $name - bucket name.
*/
public function getName();
/**
* Sets bucket file storage.
* @param StorageInterface $storage - file storage.
* @return boolean success.
*/
public function setStorage(StorageInterface $storage);
/**
* Gets bucket file storage.
* @return StorageInterface - bucket file storage.
*/
public function getStorage();
/**
* Creates this bucket.
* @return boolean success.
*/
public function create();
/**
* Destroys this bucket.
* @return boolean success.
*/
public function destroy();
/**
* Checks is bucket exists.
* @return boolean success.
*/
public function exists();
/**
* Saves content as new file.
* @param string $fileName - new file name.
* @param string $content - new file content.
* @return boolean success.
*/
public function saveFileContent($fileName, $content);
/**
* Returns content of an existing file.
* @param string $fileName - new file name.
* @return string $content - file content.
*/
public function getFileContent($fileName);
/**
* Deletes an existing file.
* @param string $fileName - new file name.
* @return boolean success.
*/
public function deleteFile($fileName);
/**
* Checks if the file exists in the bucket.
* @param string $fileName - searching file name.
* @return boolean file exists.
*/
public function fileExists($fileName);
/**
* Copies file from the OS file system into the bucket.
* @param string $srcFileName - OS full file name.
* @param string $fileName - new bucket file name.
* @return boolean success.
*/
public function copyFileIn($srcFileName, $fileName);
/**
* Copies file from the bucket into the OS file system.
* @param string $fileName - bucket existing file name.
* @param string $destFileName - new OS full file name.
* @return boolean success.
*/
public function copyFileOut($fileName, $destFileName);
/**
* Copies file inside this bucket or between this bucket and another
* bucket of this file storage.
* File can be passed as string, which means the internal bucket file,
* or as an array of 2 elements: first one - the name of the bucket,
* the second one - name of the file in this bucket
* @param mixed $srcFile - this bucket existing file name or array reference to another bucket file name.
* @param mixed $destFile - this bucket existing file name or array reference to another bucket file name.
* @return boolean success.
*/
public function copyFileInternal($srcFile, $destFile);
/**
* Copies file from the OS file system into the bucket and
* deletes the source file.
* @param string $srcFileName - OS full file name.
* @param string $fileName - new bucket file name.
* @return boolean success.
*/
public function moveFileIn($srcFileName, $fileName);
/**
* Copies file from the bucket into the OS file system and
* deletes the source bucket file.
* @param string $fileName - bucket existing file name.
* @param string $destFileName - new OS full file name.
* @return boolean success.
*/
public function moveFileOut($fileName, $destFileName);
/**
* Moves file inside this bucket or between this bucket and another
* bucket of this file storage.
* File can be passed as string, which means the internal bucket file,
* or as an array of 2 elements: first one - the name of the bucket,
* the second one - name of the file in this bucket
* @param mixed $srcFile - this bucket existing file name or array reference to another bucket file name.
* @param mixed $destFile - this bucket existing file name or array reference to another bucket file name.
* @return boolean success.
*/
public function moveFileInternal($srcFile, $destFile);
/**
* Gets web URL of the file.
* @param string $fileName - self file name.
* @return string file web URL.
*/
public function getFileUrl($fileName);
}