Comments (6)
可以加一个 exist
接口,404 不报错返回 null,还是保留 head
现在这样吧,不然这种不兼容变更不好发
from ali-oss.
增加exist方法的话其实会多一次请求:
if (client.object_exist(obj)) { // 1st req
var r = client.head(obj); // 2nd req
}
似乎是.head
返回null
更好一些。@dead-horse 怎么看?
from ali-oss.
@rockuw
最初设计时,对于想判断 object 是否存在是怎么考虑的?
有个问题,看 head 的方法是发一个请求,通过判断 statusCode。但是这样后台会增加失败访问的计数器,不利于统计。你怎么看?
from ali-oss.
OSS的API里没有相关的exist的API,怎么处理完全取决于用户。
实际上,因为下面的操作不是原子的,提供这样一个API的意义也不大,而且还会增加一次网络请求:
if (client.object_exist(obj)) { // 1st req
var r = client.head(obj); // 2nd req
}
from ali-oss.
@rockuw
实际上的用途是
if(!client.head(obj)) { // 不存在
client.put(obj);
}
我这里场景是上传队列,要做个去重
from ali-oss.
你自己封装一个函数好了:
function objectExist(client, obj) {
// xxx
}
from ali-oss.
Related Issues (20)
- Object.put 指定 file 为路径时响应没有 url 吗
- Bug: Nuxt3+ts项目 打包报错 HOT 8
- 上传失败错误-1 HOT 2
- 在vite中使用出现开发环境与生产环境表现不一致的问题 HOT 1
- VUE3+VITE 使用oss打包时报错 HOT 1
- ali-oss 不支持在 cloudflare workers 中使用 HOT 2
- 使用 6.18.1 版本在 next.js 框架下以及 nodejs v18.14.2 环境中提示依赖 proxy-agent implementation 找不到 HOT 1
- 如何实现大文件断点续传下载 HOT 1
- vite使用ali-oss时打包出错
- 能否支持CLI, 命令行调用?
- 多个文件上传,如何更新进度条
- https://registry.npm.taobao.org/ali-oss: certificate has expired HOT 1
- Nextjs Critical dependency: the request of a dependency is an expression HOT 2
- 浏览器里下载较大的文件后,无法解析,报错 RangeError: Invalid array length
- Pre signed URL does not match/预先签名URL上传jpeg照片时出现签名不符错误
- 【安全漏洞】NPM IP package vulnerable to Server-Side Request Forgery (SSRF) attacks HOT 1
- listBuckets 的类型声明
- ali-oss版本6.20.0。Vite5 打包后在使用multipartUpload分片上传时,SDK在调用InitiateMultipartUpload方法后发起的请求中,收到的请求中没办法收到响应体。在开发环境中能正常收到响应数据 HOT 1
- OSS上传回调中如何设置自定义header的
- 私有的桶,上传文件错误提示 Access denied by bucket policy
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ali-oss.