承接 miarra/filemanipulator 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

miarra/filemanipulator

Composer 安装命令:

composer require miarra/filemanipulator

包简介

library in Nette for access to fileserver which can be found at https://bitbucket.org/miarra/fileserver.git

README 文档

README

This extension comunicate with fileserver where you store images. For properly function You will need to run FileServer aplication which you can find at https://bitbucket.org/miarra/fileserver.git.

Instalation

Download

The best way to install miarra/filemanipulator, is using Composer:

$ composer require miarra/filemanipulator

Registering

You can enable the extension using your neon config:

extensions:
	FileManipulator: Miarra\FileManipulator\FileManipulatorExtension

Injecting

You can simply inject factory in Your Presenters/Services:

public function __construct(
	private \Miarra\FileManipulator\FileManipulator $fileManipulator,
) {
    parent::__construct();
    ...
}

HTACCESS

You must set RewriteRule in your .htaccess file like this:

	RewriteRule (.*\.(gif|jpg|jpeg|png|webp|bmp))$ https://urlOfYourFileserver.cz/images/$1 [P]

If your hosting doesn't support apache mod_proxy, you must use forward instead:

	RewriteRule (.*\.(gif|jpg|jpeg|png|webp|bmp))$ https://urlOfYourFileserver.cz/images/$1 [R=301,L]

Alternatively, you can use php redirect or forward.

More info: https://httpd.apache.org/docs/2.4/rewrite/flags.html#flag_p

Info about enabling apache proxy: https://www.digitalocean.com/community/tutorials/how-to-use-apache-as-a-reverse-proxy-with-mod_proxy-on-ubuntu-16-04

Setting

You must set options in a config file like this:

FileManipulator:
	url: 'http://urlOfYoursFileManipulatorServer.cz/'
	username: 'yourUsernameToFileManipulatorServer'
	password: 'yourPasswordToFileManipulatorServer'

Saving, Loading and Deleting images

Saving

For saving images you need use object of FileUploadHolder. You can get this object from factory method which is placed in FileManipulator (createFileUploadHolder()).

FileUploadHolder API

addFileUpload(FileUpload $file, string $filePath = null, bool $autogeneratePathPrefix = false) - Add single file. The Default file path is its file name. $filePath param contains location where you want to save your file. If the param $autogeneratePathPrefix is set to true $filePath params prefix is also set according to current date in /Y/m/d/ format.

addMultipleFileUpload(array $files, bool $autogeneratePathPrefix = false) - Add multiple files into the inner array. The Default file path is its file name. If the param $autogeneratePathPrefix is set to true $filePath params prefix is set according to current date in /Y/m/d/ format.

clear() - Remove all file added to FileUploadHolder instance.

When you fill FileUploadHolder you can call function $returnedUrls = $this->fileManipulator->saveImages(FileUploadHolder $files) which returns an array of base urls of upload images, so in $returnedUrls will be ["fileUrl1", "fileUrl2"] which would be compatible with your filePath specified in FileUploadHolder.

Loading

If you want to get a saved image in different size, then original, you need to send query parametres width or height (you can use one or both).

In case you don't use PROXY, you need to concatenate returned URL with an image URL path.

(Example: 'https://< yourFileServerURL.xy >/images/< yourReturnedURL >').

Examples:

Original image: $returnedUrls[$index]

Image with width 250px: $returnedUrls[$index] . '?width=250'

Image with height 500px: $returnedUrls[$index] . '?height=500'

Image with max width 600px and max height 700px: $returnedUrls[$index] . '?width=600&height=700'

Deleting

For delete images call function $this->fileManipulator->deleteImages($returnedUrls).

Copy

For copy images call function $this->fileManipulator->copyImages($returnedUrls).

Conclusion

This extension requires Nette3.0 and it is property of Miarra © 2021

统计信息

  • 总下载量: 60
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2021-03-15

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固