需要将自定义元数据值设置为来自 IntialFileList 的 dom/html

Need to set custom metadata value into dom/html that is coming from IntialFileList

我正在使用 InitalFileList 从上一个会话加载文件。我上传的文件将有额外的 s3 元数据值,我需要显示 InitialFileList 的一部分。在服务器端,我确实向 jason 对象添加了额外的元数据,我可以在控制台输出(响应)中看到它。

我的问题是.... 如何将新的metadata/property(qq-edit-caption是我模板中的输入框)设置为HTML显示。我在下面的回调中没有看到任何参数来处理 dom。非常感谢任何帮助。

onSessionRequestComplete(response, success, xhrOrXdr) {
 //
}

我的 HTML 模板:

<script type="text/template" id="qq-template-manual-trigger-section1">
    <div class="qq-uploader-selector qq-uploader" qq-drop-area-text="Drop files here">
        <div class="qq-total-progress-bar-container-selector qq-total-progress-bar-container">
            <div role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" class="qq-total-progress-bar-selector qq-progress-bar qq-total-progress-bar"></div>
        </div>
        <div class="qq-upload-drop-area-selector qq-upload-drop-area" qq-hide-dropzone>
            <span class="qq-upload-drop-area-text-selector"></span>
        </div>
        <div class="buttons">
            <div class="qq-upload-button-selector qq-upload-button">
                <div>Select files</div>
            </div>
            <button type="button" id="trigger-upload-section1" class="btn btn-primary">
                <i class="icon-upload icon-white"></i> Upload
            </button>
        </div>
        <span class="qq-drop-processing-selector qq-drop-processing">
            <span>Processing dropped files...</span>
            <span class="qq-drop-processing-spinner-selector qq-drop-processing-spinner"></span>
        </span>
        <ul class="qq-upload-list-selector qq-upload-list" aria-live="polite" aria-relevant="additions removals">
            <li>
                <div class="qq-progress-bar-container-selector">
                    <div role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" class="qq-progress-bar-selector qq-progress-bar"></div>
                </div>
                <span class="qq-upload-spinner-selector qq-upload-spinner"></span>
                <div>
                <img class="qq-thumbnail-selector" qq-max-size="80" qq-server-scale>                    
                <span class="qq-upload-file-selector qq-upload-file"></span>
                <span class="qq-upload-size-selector qq-upload-size"></span>
                <span class="qq-edit-filename-icon-selector qq-edit-filename-icon qq-editable" aria-label="Edit filename"></span>
                <input class="qq-edit-filename-selector qq-edit-filename" tabindex="0" type="text">
                </div>
                <span class="qq-upload-caption-selector qq-upload-caption"></span>
                <span class="qq-edit-caption-icon-selector qq-edit-caption-icon kk-editable" aria-label="Edit caption"></span>                    
                <input class="qq-edit-caption-selector qq-edit-caption kk-editing" placeholder="Caption  here ..." tabindex="0" type="text">
                <button type="button" class="qq-btn qq-upload-delete-selector qq-upload-update-caption" onclick="captionUpdate(true);">Update Caption</button>

                <button type="button" class="qq-btn qq-upload-cancel-selector qq-upload-cancel">Cancel</button>
                <button type="button" class="qq-btn qq-upload-retry-selector qq-upload-retry">Retry</button>
                <button type="button" class="qq-btn qq-upload-delete-selector qq-upload-delete" onclick="captionUpdate(false);">Delete</button 

                <span role="status" class="qq-upload-status-text-selector qq-upload-status-text"></span>
            </li>
        </ul>

        <dialog class="qq-alert-dialog-selector">
            <div class="qq-dialog-message-selector"></div>
            <div class="qq-dialog-buttons">
                <button type="button" class="qq-cancel-button-selector">Close</button>
            </div>
        </dialog>

        <dialog class="qq-confirm-dialog-selector">
            <div class="qq-dialog-message-selector"></div>
            <div class="qq-dialog-buttons">
                <button type="button" class="qq-cancel-button-selector">No</button>
                <button type="button" class="qq-ok-button-selector">Yes</button>
            </div>
        </dialog>

        <dialog class="qq-prompt-dialog-selector">
            <div class="qq-dialog-message-selector"></div>
            <input type="text">
            <div class="qq-dialog-buttons">
                <button type="button" class="qq-cancel-button-selector">Cancel</button>
                <button type="button" class="qq-ok-button-selector">Ok</button>
            </div>
        </dialog>
    </div>
</script> 

如果您的 onSessionRequestComplete 回调处理程序,您可以:

  1. 遍历条目。
  2. 使用 the getUploads API method.
  3. 将每个条目映射到 Fine Uploader 文件 ID
  4. 使用 the getItemByFileId API method.
  5. 获取 DOM 中每个容器元素的句柄
  6. Select 标题输入并用所需的值更新它。

例如:

onSessionRequestComplete: function(response, success) {
   if (success) {
      var uploader = this
      response.forEach(function(item) {
         var id = uploader.getUploads({uuid: item.uuid}).id
         var fileEl = uploader.getItemByFileId(id)
         fileEl.querySelector('.qq-edit-caption').value = item.caption
      })
   }
}