parse 8.2.0-alpha.2 → 8.3.0-alpha.1

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.
@@ -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.2.0-alpha.2",
194
+ VERSION: "js8.3.0-alpha.1",
195
195
  APPLICATION_ID: null,
196
196
  JAVASCRIPT_KEY: null,
197
197
  MAINTENANCE_KEY: null,
@@ -9659,6 +9659,14 @@
9659
9659
  tags() {
9660
9660
  return this._tags;
9661
9661
  }
9662
+ /**
9663
+ * Gets the directory of the file.
9664
+ *
9665
+ * @returns {string | undefined}
9666
+ */
9667
+ directory() {
9668
+ return this._directory;
9669
+ }
9662
9670
  /**
9663
9671
  * Saves the file to the Parse cloud.
9664
9672
  *
@@ -9693,13 +9701,14 @@
9693
9701
  options.requestTask = (task) => this._requestTask = task;
9694
9702
  options.metadata = this._metadata;
9695
9703
  options.tags = this._tags;
9704
+ options.directory = this._directory;
9696
9705
  const controller = CoreManager.getFileController();
9697
9706
  if (!this._previousSave) {
9698
9707
  if (this._source.format === "buffer" || this._source.format === "stream") {
9699
- const hasMetadataOrTags = this._metadata && Object.keys(this._metadata).length > 0 || this._tags && Object.keys(this._tags).length > 0;
9700
- if (this._source.format === "stream" && hasMetadataOrTags) {
9708
+ const hasFileData = this._metadata && Object.keys(this._metadata).length > 0 || this._tags && Object.keys(this._tags).length > 0 || !!this._directory;
9709
+ if (this._source.format === "stream" && hasFileData) {
9701
9710
  throw new Error(
9702
- "Cannot save a stream-based file with metadata or tags. Use a Buffer instead."
9711
+ "Cannot save a stream-based file with metadata, tags, or directory. Use a Buffer instead."
9703
9712
  );
9704
9713
  }
9705
9714
  if (this._source.format === "stream" && !controller.saveBinary) {
@@ -9707,7 +9716,7 @@
9707
9716
  "Cannot save a stream-based file without saveBinary support on the FileController."
9708
9717
  );
9709
9718
  }
9710
- if (!hasMetadataOrTags && controller.saveBinary) {
9719
+ if (!hasFileData && controller.saveBinary) {
9711
9720
  this._previousSave = controller.saveBinary(this._name, this._source, options).then((res) => {
9712
9721
  this._name = res.name;
9713
9722
  this._url = res.url;
@@ -9863,6 +9872,17 @@
9863
9872
  this._tags[key2] = value;
9864
9873
  }
9865
9874
  }
9875
+ /**
9876
+ * Sets the directory where the file will be stored.
9877
+ * Requires the Master Key when saving.
9878
+ *
9879
+ * @param {string} directory the directory path
9880
+ */
9881
+ setDirectory(directory) {
9882
+ if (typeof directory === "string" && directory.length > 0) {
9883
+ this._directory = directory;
9884
+ }
9885
+ }
9866
9886
  static fromJSON(obj) {
9867
9887
  if (obj.__type !== "File") {
9868
9888
  throw new TypeError("JSON object does not represent a ParseFile");
@@ -9918,11 +9938,13 @@
9918
9938
  base64: source.base64,
9919
9939
  fileData: {
9920
9940
  metadata: { ...options.metadata },
9921
- tags: { ...options.tags }
9941
+ tags: { ...options.tags },
9942
+ ...options.directory ? { directory: options.directory } : {}
9922
9943
  }
9923
9944
  };
9924
9945
  delete options.metadata;
9925
9946
  delete options.tags;
9947
+ delete options.directory;
9926
9948
  if (source.type) {
9927
9949
  data._ContentType = source.type;
9928
9950
  }