robotkudos/rk-image-api 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

robotkudos/rk-image-api

Composer 安装命令:

composer require robotkudos/rk-image-api

包简介

API for processing image upload to work with rk-image-uploader React app.

README 文档

README

RK Image API handles the backend for rk-image-uploader. It receives api requests from rk-image-uploader and response securely.

Install

composer require robotkudos/rk-image-api

Usage

By default, RKImageAPI respond to /api/image-api with auth:api middleware. It will create a table named images and will be ready as soon as it's been installed. All you need to do it run following command to create the images table:

php artisan migrate

Config

If you need extra security (by adding more middlewares) or different api endpoint as well as changing the table name, you can publish vendor config file with the following command:

php artisan vendor:publish --provider='RobotKudos/RKImageAPI/RKImageAPIServiceProvider'

This will copy config file into config/rkimageapi.php. You can change the default values there.

APIs

POST /api/image-api

Receives the following

- image (FormData Image)
- key (random stringto group images, e.g. by user, or listing, ...)
- name
- position (the position for sorting purpose)
- comment (optional)

Response sample

{
    err: false, 
    id: 123
}

GET /api/image/api

Receives the following:

- key

Response sample

[
    {
        id: 123,
        name: sample_name,
        image_url: /img/sample_name.jpg,
        image_2x_url: /img/sample_name_2x.jpg,
        thumb_url: /img/sample_name_thumb.jpg,
        thumb_2x_url: /img/sample_name_thumb_2x.jpg,
        position: 1,
        comments: ...
     }
]

DELETE /api/image-api

It deletes all images with the key.

Receives the following:

- key

Response sample

{
    err: false
}

PUT /api/image-api/{id}

Edit the name of image.

Receives the following:

- action: rename // currenty only support rename
- name: the new name

Response sample

{
    err: false,
    name: new name
}

PUT /api/image-api/reorder

Swap the position of two images.

Receives

- id1
- pos1
- id2
- pos2

Response sample

{
    err: false
}

DELETE /api/image-api/{id}

Deletes the image

Receives no content

Response sample:

{
    err: false
}

Dig deeper

RKImageAPI needs to receive a key to group images. It creates four images for each image it receives. One normal size (by default 1500px, you can change it via config file), one double that size as Retina version, one thumb size (by default 180px, configurable via config file) and one double the thumb size for retina.

Under the hood, it uses RKImage package for resizing and saving the image.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-10-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固