Skip to content

Commit ff3db71

Browse files
authored
refactor: create Object directly when upload file with URL (#625)
1 parent 82d6580 commit ff3db71

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# Master
2+
3+
### Internal Changes
4+
5+
- 现在保存通过 `AV.File.withURL` 方法创建的文件等同于直接在 \_File 中添加一行数据,不再自动生成 `mime_type`
6+
17
# 4.7.0(2020-07-14)
28

39
### Features

src/file.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ module.exports = function(AV) {
183183
file.attributes.url = url;
184184
//Mark the file is from external source.
185185
file.attributes.metaData.__source = 'external';
186+
file.attributes.metaData.size = 0;
186187
return file;
187188
};
188189

@@ -595,18 +596,13 @@ module.exports = function(AV) {
595596
};
596597
this._previousSave = AVRequest(
597598
'files',
598-
this.attributes.name,
599+
null,
599600
null,
600601
'post',
601602
data,
602603
options
603604
).then(response => {
604-
this.attributes.name = response.name;
605-
this.attributes.url = response.url;
606605
this.id = response.objectId;
607-
if (response.size) {
608-
this.attributes.metaData.size = response.size;
609-
}
610606
return this;
611607
});
612608
}

0 commit comments

Comments
 (0)