Scalable Image Storage

前端 未结 11 581
半阙折子戏
半阙折子戏 2020-12-12 09:42

I\'m currently designing an architecture for a web-based application that should also provide some kind of image storage. Users will be able to upload photos as one of the k

11条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-12 10:07

    Here is an example to store blob image in CouchDB using PHP Laravel. In this example, I am storing three images based on user requirements.

    Establishing the connection in CouchDB.

    $connection = DB::connection('your database name');
    
    /*region Fetching the Uers Uploaded Images*/
    
    $FirstImage = base64_encode(file_get_contents(Input::file('FirstImageInput')));
    $SecondImage =base64_encode(file_get_contents(Input::file('SecondImageInput')));
    $ThirdImage = base64_encode(file_get_contents(Input::file('ThirdImageInput')));
    
    list($id, $rev) = $connection->putDocument(array(
        'name' => $name,
        'location' => $location,
        'phone' => $phone,
        'website' => $website,
        "_attachments" =>[
            'FirstImage.png' => [
                'content_type' => "image/png",
                'data' => $FirstImage
            ],
            'SecondImage.png' => [
                'content_type' => "image/png",
                'data' => $SecondImage
            ],
            'ThirdImage.png' => [
                'content_type' => "image/png",
                'data' => $ThirdImage
            ]
        ],
    ), $id, $rev);
    
    ...
    

    same as you can store single image.

提交回复
热议问题