filestack / filestack-js

Official Javascript SDK for the Filestack API and content ingestion system.
https://www.filestack.com
MIT License
206 stars 77 forks source link

Cannot upload filestack by url when there is accept parameter #374

Closed golf-x closed 1 year ago

golf-x commented 4 years ago
import React, { useEffect } from "react";
import * as filestack from "filestack-js";

function App() {
  useEffect(() => {
    const fileStackApiKey = "";
    const client = filestack.init(fileStackApiKey);
    const picker = client.picker({
      accept: [
        ".jpg",
        ".jpeg",
        ".png",
        ".gif",
        ".tif",
        ".tiff",
        ".webm",
        ".mpg",
        ".mp2",
        ".mpeg",
        ".mpe",
        ".mpv",
        ".mp4",
        ".m4p",
        ".m4v",
        ".avi",
        ".mov",
        ".wmv",
        ".qt",
        ".txt",
        ".pdf",
        ".ods",
        ".xlsx",
        ".xls",
        ".xlsm",
        ".doc",
        ".docx",
        ".odt",
        ".rtf",
        ".wpd",
        ".ppt",
        ".pptx",
        ".pages",
        ".numbers",
        ".key",
        ".xml",
        ".xlsb",
      ],
      onUploadDone: (files) => {
        console.log("files ===", files);
      },
    });
    picker.open();
  }, []);

  return (
    <div>
      <div id="droppane"></div>
    </div>
  );
}

export default App;

When try to upload by url it will cause error cannot read length of undefined It seems that when upload by url filename will always be undefined thus cause this eror

ktranada commented 4 years ago

Your accept options consist of explicit extensions. When you upload from a url, the url might not contain the extension. To get around this, you'll want to add this option: image/jpeg. Prefer to use mimetype's over extensions for better handling