I have created the custom attribute to upload the business proof file during registration. I am able to store the file in /pub/media and file name in Database and the file name also displaying in customer grid.

How to access the file from admin? Shall we create the href to that column in customer grid to access the file. I have added the screen shot below for reference.

enter image description here

1 Answer 1


Try following way:

  1. Add column into your grid list


<column name="reference" class="Vendor\Module\Ui\Component\Listing\Columns\Reference">
    <argument name="data" xsi:type="array">
        <item name="config" xsi:type="array">
            <item name="component" xsi:type="string">Vendor_Module/js/grid/columns/reference</item>
            <item name="sortable" xsi:type="boolean">false</item>
            <item name="label" xsi:type="string" translate="true">Reference</item>
            <item name="sortOrder" xsi:type="number">20</item>
  1. Create a column class


namespace Vendor\Module\Ui\Component\Listing\Columns;

use Magento\Framework\View\Element\UiComponentFactory;
use Magento\Framework\View\Element\UiComponent\ContextInterface;

class Reference extends \Magento\Ui\Component\Listing\Columns\Column
    const NAME = 'reference';

    const ALT_FIELD = 'name';

     * @param ContextInterface $context
     * @param UiComponentFactory $uiComponentFactory
     * @param \Magento\Framework\UrlInterface $urlBuilder
     * @param array $components
     * @param array $data
    public function __construct(
        ContextInterface $context,
        UiComponentFactory $uiComponentFactory,
        \Magento\Framework\UrlInterface $urlBuilder,
        array $components = [],
        array $data = []
    ) {
        parent::__construct($context, $uiComponentFactory, $components, $data);
        $this->urlBuilder = $urlBuilder;

     * Prepare Data Source
     * @param array $dataSource
     * @return array
    public function prepareDataSource(array $dataSource)
        if (isset($dataSource['data']['items'])) {
            $fieldName = $this->getData('name');
            foreach ($dataSource['data']['items'] as & $item) {
                $label = $item[$fieldName];
                $item[$fieldName.'_Url'] = $this->urlBuilder->getUrl(
                $item[$fieldName.'_Label'] = $label;

        return $dataSource;
  1. Create component


], function (Column, $, mageTemplate) {
    'use strict';

    return Column.extend({
        defaults: {
            bodyTmpl: 'Vendor_Module/grid/cells/reference',
            fieldClass: {
                'data-grid-actions-cell': true
        getLabel: function (record) {
            return record[this.index+'_Label'];
        getUrl: function (record) {
            return record[this.index+'_Url'];
  1. Create template


  attr="href: $col.getUrl($row())"/>
  1. Clear cache
$  php bin/magento cache:flush
$  php bin/magento cache:clean
  • thank you for providing the solution. I will check and let you know. Commented Feb 3, 2017 at 10:52
  • Is it working for you ? Commented Mar 24, 2017 at 13:09
  • I didn't check but I did it in alternate way(added it in Customer Grid->Edit->Customer View->Personal Information) because I have added lot of fields. There, I added the href to uploaded files. Commented Mar 24, 2017 at 13:25
  • I use your tricks. Its working fine. Thank you!! Commented Mar 25, 2017 at 4:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.