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)
- 身为一个开发者,求稳是美德。 6.17版 HOT 3
- 依赖包中vm2存在严重的沙箱逃逸漏洞,是否考虑升级版本修复? HOT 3
- jest测试ali-oss报错:SyntaxError: Cannot use import statement outside a module HOT 3
- import 报错,报未定义 HOT 1
- list方法为什么只能返回1000限制?几万个文件怎么办? HOT 3
- 当我使用nuxt3 来使用ali-oss 的上传功能,在build的时候发生这个问题 HOT 1
- cancel如何暂停某个文件的上传 HOT 1
- Node 最新版本 enableProxy 导致找不到 x-oss-request-id HOT 3
- 6.18.0 更新日志在哪里?是 npm 账号被盗用了么? HOT 3
- window is not defined in webworker HOT 2
- Is there a way to multipart upload with signedUrl?
- 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时打包出错
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.