function Introduction
Web developers often need to deal with all kinds of information uploaded by users, such as pictures, attachments, documents, and so on, which are generally stored in the server's local space. However, in a distributed environment such as ACE, storage and locality are not conducive to the automatic expansion and recycling of servers determined by processing access capabilities, so ACE provides storage services. Developers can gain distributed storage capabilities and space through the storage service.
Instructions for use
Using storage eliminates the need for developers to add any library files to their code without requesting their own keys, without having to manually create a stored "folder" name, just calling an interface similar to a file operation.
Reference sample
$file _url = $storage->upload ("Test.jpg", "title.jpg");
$file _url would be xxx.aliapp.com/aliyun_ce_storage/title.jpg
}
$file _lists = $storage->getlist ();
if ($stoage->fileexists ("title.jpg")) {
$content = $storage->read ("title.jpg");
}
?>
API documentation
String upload (String $srcFileName, String $destFileName)
Upload the file and save it to the storage server.
Parameters:
Srcfilename
File name to upload
destFileName
Save file name
return value:
Success returns the file access address, or false.
String Read (String $filename)
Read the contents of the file.
Parameters:
The file name read
return value:
Returns the contents of the file successfully, otherwise false.
String GetUrl (String $filename)
Gets the URL that accesses the file.
Parameters:
FileName
File name to get
return value:
Success returns the URL, or false.
String Delete (string $filename)
Deletes a file.
Parameters:
FileName
File name that needs to be deleted
return value:
Returns true successfully, otherwise false.
String FileExists (String $filename)
Determine if a file exists.
Parameters:
FileName
File name that needs to be judged
return value:
The existence returns TRUE, otherwise false.
Array GetList ([String $prefix = '],[int $num =100], [string $marker = '], [$delimiter = '])
Get file List
Prefix
Matching prefix for query
Num
Number of files listed at a time
Marker
Lists the starting location of the file, such as a.jpg.
Delimiter
If the delimiter is set to / , the return value lists only the files under that folder, and the recursive files and folders under the subfolder are not displayed.
return value:
Successfully returned array of file list, failed false.
String ErrMsg ()
Gets the error message.
return value:
Returns an error message.
int errno ()
Gets the error code.
return value:
Returns the error code.
Error MSG:
errno:0 successful
errno:-1 parameter error
errno:-400 invalid parameter
errno:-404 object does not exist
errno:-500 Server Internal Error