parse 8.2.0 → 8.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/parse.js +30 -6
- package/dist/parse.min.js +1 -1
- package/dist/parse.weapp.js +30 -6
- package/dist/parse.weapp.min.js +1 -1
- package/lib/browser/CoreManager.js +1 -1
- package/lib/browser/ParseFile.js +34 -6
- package/lib/node/CoreManager.js +1 -1
- package/lib/node/ParseFile.js +33 -5
- package/lib/react-native/CoreManager.js +1 -1
- package/lib/react-native/ParseFile.js +22 -6
- package/lib/weapp/CoreManager.js +1 -1
- package/lib/weapp/ParseFile.js +34 -6
- package/package.json +1 -1
- package/types/ParseFile.d.ts +17 -0
package/dist/parse.weapp.js
CHANGED
|
@@ -191,7 +191,7 @@
|
|
|
191
191
|
SERVER_URL: "https://api.parse.com/1",
|
|
192
192
|
LIVEQUERY_SERVER_URL: null,
|
|
193
193
|
ENCRYPTED_KEY: null,
|
|
194
|
-
VERSION: "js8.
|
|
194
|
+
VERSION: "js8.3.0",
|
|
195
195
|
APPLICATION_ID: null,
|
|
196
196
|
JAVASCRIPT_KEY: null,
|
|
197
197
|
MAINTENANCE_KEY: null,
|
|
@@ -9659,6 +9659,15 @@
|
|
|
9659
9659
|
tags() {
|
|
9660
9660
|
return this._tags;
|
|
9661
9661
|
}
|
|
9662
|
+
/**
|
|
9663
|
+
* Gets the directory of the file.
|
|
9664
|
+
* Requires Parse Server >= 9.4.0.
|
|
9665
|
+
*
|
|
9666
|
+
* @returns {string | undefined}
|
|
9667
|
+
*/
|
|
9668
|
+
directory() {
|
|
9669
|
+
return this._directory;
|
|
9670
|
+
}
|
|
9662
9671
|
/**
|
|
9663
9672
|
* Saves the file to the Parse cloud.
|
|
9664
9673
|
*
|
|
@@ -9693,13 +9702,14 @@
|
|
|
9693
9702
|
options.requestTask = (task) => this._requestTask = task;
|
|
9694
9703
|
options.metadata = this._metadata;
|
|
9695
9704
|
options.tags = this._tags;
|
|
9705
|
+
options.directory = this._directory;
|
|
9696
9706
|
const controller = CoreManager.getFileController();
|
|
9697
9707
|
if (!this._previousSave) {
|
|
9698
9708
|
if (this._source.format === "buffer" || this._source.format === "stream") {
|
|
9699
|
-
const
|
|
9700
|
-
if (this._source.format === "stream" &&
|
|
9709
|
+
const hasFileData = this._metadata && Object.keys(this._metadata).length > 0 || this._tags && Object.keys(this._tags).length > 0 || !!this._directory;
|
|
9710
|
+
if (this._source.format === "stream" && hasFileData) {
|
|
9701
9711
|
throw new Error(
|
|
9702
|
-
"Cannot save a stream-based file with metadata or
|
|
9712
|
+
"Cannot save a stream-based file with metadata, tags, or directory. Use a Buffer instead."
|
|
9703
9713
|
);
|
|
9704
9714
|
}
|
|
9705
9715
|
if (this._source.format === "stream" && !controller.saveBinary) {
|
|
@@ -9707,7 +9717,7 @@
|
|
|
9707
9717
|
"Cannot save a stream-based file without saveBinary support on the FileController."
|
|
9708
9718
|
);
|
|
9709
9719
|
}
|
|
9710
|
-
if (!
|
|
9720
|
+
if (!hasFileData && controller.saveBinary) {
|
|
9711
9721
|
this._previousSave = controller.saveBinary(this._name, this._source, options).then((res) => {
|
|
9712
9722
|
this._name = res.name;
|
|
9713
9723
|
this._url = res.url;
|
|
@@ -9863,6 +9873,18 @@
|
|
|
9863
9873
|
this._tags[key2] = value;
|
|
9864
9874
|
}
|
|
9865
9875
|
}
|
|
9876
|
+
/**
|
|
9877
|
+
* Sets the directory where the file will be stored.
|
|
9878
|
+
* Requires the Master Key when saving.
|
|
9879
|
+
* Requires Parse Server >= 9.4.0.
|
|
9880
|
+
*
|
|
9881
|
+
* @param {string} directory the directory path
|
|
9882
|
+
*/
|
|
9883
|
+
setDirectory(directory) {
|
|
9884
|
+
if (typeof directory === "string" && directory.length > 0) {
|
|
9885
|
+
this._directory = directory;
|
|
9886
|
+
}
|
|
9887
|
+
}
|
|
9866
9888
|
static fromJSON(obj) {
|
|
9867
9889
|
if (obj.__type !== "File") {
|
|
9868
9890
|
throw new TypeError("JSON object does not represent a ParseFile");
|
|
@@ -9918,11 +9940,13 @@
|
|
|
9918
9940
|
base64: source.base64,
|
|
9919
9941
|
fileData: {
|
|
9920
9942
|
metadata: { ...options.metadata },
|
|
9921
|
-
tags: { ...options.tags }
|
|
9943
|
+
tags: { ...options.tags },
|
|
9944
|
+
...options.directory ? { directory: options.directory } : {}
|
|
9922
9945
|
}
|
|
9923
9946
|
};
|
|
9924
9947
|
delete options.metadata;
|
|
9925
9948
|
delete options.tags;
|
|
9949
|
+
delete options.directory;
|
|
9926
9950
|
if (source.type) {
|
|
9927
9951
|
data._ContentType = source.type;
|
|
9928
9952
|
}
|