GithubHelp home page GithubHelp logo

react-component / upload Goto Github PK

View Code? Open in Web Editor NEW
771.0 33.0 309.0 8.57 MB

React Upload

Home Page: https://upload.react-component.vercel.app/

License: MIT License

JavaScript 3.85% TypeScript 96.15%

upload's Issues

beforeUpload 中 Promise.reject 的处理

@shepherdwind

你好,我在 beforeUpload中 如果抛出了Promise.reject的异常,IE和火狐等浏览器都会出现
Unhandled promise rejection的错误;

能否在源码 AjaxUploader文件里面的upload方法里面:

if(before&&before.then) { before.then(...) }

添加一个异常捕获处理?

if(before&&before.then) { before.then(...).catch((err)=>{}) }

abort with customRequest

I have an Upload form item that uses a customRequest. I'm getting an error when trying to leave the page:

AjaxUploader.js:185 Uncaught TypeError: Cannot read property 'abort' of undefined
at eval (webpack:///./~/rc-upload/lib/AjaxUploader.js?:185:18)

How can i manually abort the upload or signal to AjaxUploader that the request was completed through the custom request?

ie8下,服务器端应该返回怎么样的结果

我在做ie8下的调试,但是不是很明白你们提供的IE8/9的Note的意思。
项目后端用的nodejs,目前返回的结果是

    <script>document.domain="localhost"</script>  + {} //发送过来的数据中好像没有domain,我这里返回“”或者null也都不可以

前端会提醒返回document.domain的script标签,并且显示拒绝访问。
后端返回的数据有问题吗
谢谢

移动端上传问题

2.0.4 版本 使用拍照上传可以成功,但是选择相册没有上传而是直接onsuccess 返回的参数为“”

请问 onchange 的返回详细格式是什么?

{
   uid: 'uid',      // 文件唯一标识,建议设置为负数,防止和内部产生的 id 冲突
   name: 'xx.png'   // 文件名
   status: 'done',  // 状态有:uploading done error removed
   response: '{"status": "success"}',  // 服务端响应内容
}
file 除了这些字段还有那些?thumbUrl 是这里的吗??

fileList 的格式是这样的吗

[{
        uid: -1,
        name: 'xxx.png',
        status: 'done',
        url: 'https://os.alipayobjects.com/rmsportal/NDbkJhpzmLxtPhB.png',
        thumbUrl: 'https://os.alipayobjects.com/rmsportal/NDbkJhpzmLxtPhB.png',
      }]

event 具体是什么??

麻烦了 谢谢
@afc163

上传网络资源

上传网络图片资源到指定服务器该怎么做呢,好像点击上传没有提供回调,都是打开本地文件

reqs[uid].abort is not a function

触发场景: 使用自定义上传事件customRequest,当用户点击上传列表的取消按钮的时候报错:

reqs[uid].abort is not a function

更改AjaxUploader.jsx组件中
判断

if (reqs[uid].abort) {
    reqs[uid].abort();
    delete reqs[uid];
}

修复

cancel upload

how to cancel upload
this.refs.inner.abort is not supplied

选择文件后如何阻止文件上传

在上传之前,有时候需要对已选择的文件进行校验,例如大小、类型等等。
目前可以在onStart中进行校验,但是校验失败时,无法阻止上传请求的发送。

JWT support?

请问一下 upload 组件在 post 时候怎样在添加 headers 里面加入token 信息呢?

比如:

Authorization: Bearer .....

upload上传文件携带cookie的问题

XMLHttpRequest可以在跨域请求时发送认证信息,但在默认情况下HTTP Cookies和HTTP 认证是不被发送的。要发送Preflighted 认证请求需要设置XMLHttpRequest对象的withCredentials属性。

我到源码改了withCredentials属性为true,这时候请求头才会携带cookie,当请求头没有cookie的时候,后台返回的是不在线状态
image

上传文件带cookie

如题,上传时没有带cookie,导致需要登录的应用在上传的时候无法成功。可否加上在请求中加上credential.

经过测试request.js中加上

  xhr.withCredentials = true;

就可以

怎么改请求的方法为PUT ?

最近用antd Upload组件上传文件时,发现组件默认的是使用POST方法,且没有办法改,请问是否支持PUT上传文件?不支持是否有什么方案解决?谢谢

Domain Problem

请教下,这个问题不是很明白。
IE9,后端响应格式已经设置text/html,内容也有添加<script>document.domain=***</script>,
报参数无效。

图片 beforeUpload 时的宽高检测

我的尝试是:

beforeUpload={(file) => {
    const img = new Image()
    img.src = URL.createObjectURL(file)
    img.onload = () => {
        // ... 进行 naturalWidth, naturalHeight 检测 
    }
}}

但是在 onload 时,没有办法在 beforeUploadreturn false
只能够在上传完成后进行宽高检测吗?

SSR support

现在 Upload 在 node 环境下渲染会用 IframeUploader,浏览器下渲染会用 AjaxUploader,导致两边渲染结果不同,做 SSR 的时候 React 会有警告。

阿里云oss参数错误

阿里OSS上传文件忽略file字段之后的参数,amazon s3同样存在该问题

request.js 39行放到44行后面可以解决。

data参数中出现双引号会出错

for (const key in data) { if (data.hasOwnProperty(key)) { inputs.push(); } }
源代码中这里用拼字符串的方式插入表单节点,如果data[key]中有双引号,会造成值设置失败。
建议改成createElement之后设置value的方式插入节点。

form 不能嵌套

<form>
<Upload />
<form>

ie9 渲染出错,需要将 upload form 移到 body 上然后绝对定位

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.