PHP Class BookStack\Services\AttachmentService

Inheritance: extends UploadService
显示文件 Open project: ssddanbrown/bookstack

Public Methods

Method Description
deleteFile ( Attachment $attachment ) Delete a File from the database and storage.
getAttachmentFromStorage ( Attachment $attachment ) : string Get an attachment from storage.
saveNewFromLink ( string $name, string $link, integer $page_id ) : Attachment Save a new File attachment from a given link and name.
saveNewUpload ( Symfony\Component\HttpFoundation\File\UploadedFile $uploadedFile, integer $page_id ) : Attachment Store a new attachment upon user upload.
saveUpdatedUpload ( Symfony\Component\HttpFoundation\File\UploadedFile $uploadedFile, Attachment $attachment ) : Attachment Store a upload, saving to a file and deleting any existing uploads attached to that file.
updateFile ( Attachment $attachment, $requestData ) : Attachment Update the details of a file.
updateFileOrderWithinPage ( array $attachmentList, $pageId ) Updates the file ordering for a listing of attached files.

Protected Methods

Method Description
deleteFileInStorage ( Attachment $attachment ) Delete a file from the filesystem it sits on.
putFileInStorage ( $attachmentName, Symfony\Component\HttpFoundation\File\UploadedFile $uploadedFile ) : string Store a file in storage with the given filename

Private Methods

Method Description
getStorageBasePath ( ) : string Get the file storage base path, amended for storage type.

Method Details

deleteFile() public method

Delete a File from the database and storage.
public deleteFile ( Attachment $attachment )
$attachment BookStack\Attachment

deleteFileInStorage() protected method

Cleans any empty leftover folders.
protected deleteFileInStorage ( Attachment $attachment )
$attachment BookStack\Attachment

getAttachmentFromStorage() public method

Get an attachment from storage.
public getAttachmentFromStorage ( Attachment $attachment ) : string
$attachment BookStack\Attachment
return string

putFileInStorage() protected method

Store a file in storage with the given filename
protected putFileInStorage ( $attachmentName, Symfony\Component\HttpFoundation\File\UploadedFile $uploadedFile ) : string
$attachmentName
$uploadedFile Symfony\Component\HttpFoundation\File\UploadedFile
return string

saveNewUpload() public method

Store a new attachment upon user upload.
public saveNewUpload ( Symfony\Component\HttpFoundation\File\UploadedFile $uploadedFile, integer $page_id ) : Attachment
$uploadedFile Symfony\Component\HttpFoundation\File\UploadedFile
$page_id integer
return BookStack\Attachment

saveUpdatedUpload() public method

Store a upload, saving to a file and deleting any existing uploads attached to that file.
public saveUpdatedUpload ( Symfony\Component\HttpFoundation\File\UploadedFile $uploadedFile, Attachment $attachment ) : Attachment
$uploadedFile Symfony\Component\HttpFoundation\File\UploadedFile
$attachment BookStack\Attachment
return BookStack\Attachment

updateFile() public method

Update the details of a file.
public updateFile ( Attachment $attachment, $requestData ) : Attachment
$attachment BookStack\Attachment
$requestData
return BookStack\Attachment

updateFileOrderWithinPage() public method

Updates the file ordering for a listing of attached files.
public updateFileOrderWithinPage ( array $attachmentList, $pageId )
$attachmentList array
$pageId