alchemy-media 0.9.0-alpha.3 → 0.9.0-alpha.4
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/CHANGELOG.md +6 -2
- package/model/media_raw_model.js +15 -10
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
## 0.9.0-alpha.
|
|
1
|
+
## 0.9.0-alpha.4 (2024-10-10)
|
|
2
2
|
|
|
3
|
-
*
|
|
3
|
+
* Make `MediaRaw#addFile(url)` support data uris too
|
|
4
|
+
|
|
5
|
+
## 0.9.0-alpha.3 (2024-08-16)
|
|
6
|
+
|
|
7
|
+
* Implement Alchemy v1.4 `Field` changes
|
|
4
8
|
|
|
5
9
|
## 0.9.0-alpha.2 (2024-02-19)
|
|
6
10
|
|
package/model/media_raw_model.js
CHANGED
|
@@ -192,7 +192,7 @@ MediaRaw.Document.setMethod(function extraImportFromStream(input) {
|
|
|
192
192
|
*
|
|
193
193
|
* @author Jelle De Loecker <jelle@develry.be>
|
|
194
194
|
* @since 0.0.1
|
|
195
|
-
* @version 0.
|
|
195
|
+
* @version 0.9.0
|
|
196
196
|
*
|
|
197
197
|
* @param {String} file The path to the file, can be a URL
|
|
198
198
|
* @param {Object} options
|
|
@@ -217,8 +217,11 @@ MediaRaw.setMethod(function addFile(file, options, callback) {
|
|
|
217
217
|
file = file.path;
|
|
218
218
|
}
|
|
219
219
|
|
|
220
|
+
let is_url = file.startsWith('http://') || file.startsWith('https://'),
|
|
221
|
+
is_data_uri = !is_url && file.startsWith('data:');
|
|
222
|
+
|
|
220
223
|
// If the given file is actually a url, we'll need to download it first
|
|
221
|
-
if (
|
|
224
|
+
if (is_url || is_data_uri) {
|
|
222
225
|
|
|
223
226
|
// Set the url as the origin
|
|
224
227
|
options.origin = file;
|
|
@@ -232,16 +235,18 @@ MediaRaw.setMethod(function addFile(file, options, callback) {
|
|
|
232
235
|
return callback(err);
|
|
233
236
|
}
|
|
234
237
|
|
|
235
|
-
if (!
|
|
236
|
-
options.filename
|
|
237
|
-
|
|
238
|
+
if (!is_data_uri) {
|
|
239
|
+
if (!options.filename) {
|
|
240
|
+
options.filename = filename;
|
|
241
|
+
}
|
|
238
242
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
243
|
+
if (!options.filename) {
|
|
244
|
+
options.filename = Url.parse(file).pathname.split('/').last();
|
|
245
|
+
}
|
|
242
246
|
|
|
243
|
-
|
|
244
|
-
|
|
247
|
+
if (!options.name) {
|
|
248
|
+
options.name = options.filename.beforeLast('.') || options.filename;
|
|
249
|
+
}
|
|
245
250
|
}
|
|
246
251
|
|
|
247
252
|
that.addFile(tempfile, options, callback);
|