Open ddaydd opened 4 months ago
@bratelefant @jankapunkt @harryadel do we have bug in beta/rc release?
@ddaydd have you found a solution?
no, and I saw that findOne became findOneAsync but no insertAsync?
@ddaydd .insert
is client only and only mimics .insert
method of mongodb driver
thank you for motivating me... I found the _id
...
let fileId;
upload.on('start', function () {
fileId = this.config.fileId
});
...
@ddaydd I'm sure it's available via this
inside end
event as well
Yes, i confirm, but I leave it open, this must at least be changed or documented. thanks.
I'm seeing this on the client in the upload.on('end')
callback. The resulting fileObj
doesn't include a _id
like it used to. Anyone else experiencing this?
Using ostrio:files@3.0.0-beta.6
Seems you need to access the fileId
through the uploadInstance
config element in ostrio:files@3.0.0-beta.6
For example:
var uploadInstance = Images.insert({
file: file,
chunkSize: 'dynamic'
}, false);
uploadInstance.on('end', function () {
console.log('File _id: ', uploadInstance.config.fileId);
});
uploadInstance.start();
@donstephan
.fileId
as to _id
of the file as they may differ for obfuscation purposes (built-into this package)this
context?~In the example I shared above there's no this
context relevant to the file upload. This is strictly client side. The resulting fileObj
doesn't have any _id
on it like it used to.~
The resulting this
context doesn't contain a fileId
. this.config.fileId
is the only place a reference the fileId
exists.
To clarify, even though I'm listening to the 'end'
event, the fileId
in the uploadInstance
potentially isn't the resulting _id
of the file per obfuscation (which is fair).
Is this related to this comment in the 3.0 PR? https://github.com/veliovgroup/Meteor-Files/pull/884#discussion_r1612953210
I can share a test if needed.
Ok, when I eventually started moving my full app to 3.0.1 I also can confirm this is a breaking change. I don't get a proper fileRef in the "uploaded" event listener callback; worked fine in 2.16. Trying to figure this out...
I'm having the same issue after updating to meteor 3.0 and using v3.0.0-beta.6. I also found that the onUploaded hook doesn't work properly anymore. It doesn't return an error/fileObj and this is undefined and it also runs instantly after submitting. I'm not sure if this is intended, as it isn't very clear what is new in v3.
Running the following code:
const upload = ElementPhotos.insert(photoObject, false);
upload.on("end", function () {
console.log({ thisInstance: this });
console.log("File _id: ", upload.config.fileId);
});
The "this" instance contains some details about the file upload and the upload.config.fileId is a random string, but as dr-dimitru pointed out, this shouldn't be used for the required usage.
I also needed to update my s3 code to fix some issues, now that the collections are also using async functions like findOneAsync, updateAsync and removeAsync. This will also need to be updated in the types, or preferably have the types be added to the package so it wouldn't be necessary to update types manually.
Ok just pushed https://github.com/veliovgroup/Meteor-Files/pull/884/commits/d57374198218b178f4a88800fdf8a0dd8c4cc7f9 This should return the fileObj after it was inserted in the db on "end" and "uploaded" events on the client. Feel free to test and comment
Just installed the package locally with your latest changes and can confirm that this fixed the issue. It now returns the expected object in both the end callback and the onUploaded that includes the _id of the newly inserted file/image and more.
Thank you for your support and hard work on upgrading this package!
Hello,
with the 3.0.0-beta.6 version, how to retrieve the id?
Thanks.