-
-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot modify the fileRecord in upload handler #53
Comments
the reactive (i.e: reflected in the v-model instance) properties of {
progress: 0,
name: 'Some name.txt'
// ...
}
As your use makes a lot of sense, maybe
The ideal solution would be (after implementing uploaded(event) {
var responses = Array.isArray(event) ? event : [event]
for (var response of responses) {
var respObj = response.data
var backendResponse = respObj.result.files.file[0] //this is the way my backend returns it
var fileRecord = response.fileRecord
fileRecord.url(backendResponse.url)
}
}, Workaround for now: uploaded(event) {
var responses = Array.isArray(event) ? event : [event]
for (var response of responses) {
var respObj = response.data
var backendResponse = respObj.result.files.file[0] //this is the way my backend returns it
var fileRecord = response.fileRecord
var index = this.fileRecords.indexOf(fileRecord);
// for re-calculation
this.fileRecords[index] = {
name: fileRecord.name,
// ...
url: backendResponse.url,
}
}
}, |
I've tried that but it's still not reactive. |
This is the exact code I'm using:
|
You have to fill other props as well this.fileRecords[index] = {
name: fileRecord.name,
// ... other props!
url: backendResponse.url,
} |
The required props for preloading: {
"name":"Some.exe",
"size": 8165824,
"type": "application/vnd.microsoft.portable-executable",
"ext":"exe",
} |
Thanks a lot safrazik for your help & time. I did that update:
But I still see this in my model (I made a simple
|
uploaded (ev) {
var files = Array.isArray(ev) ? ev : [ev]
for (var file of files) {
var respObj = JSON.parse(file.request.response)
var backendObj = respObj.result.files.file[0]
var fileRecord = file.fileRecord
var index = this.fileRecords.indexOf(fileRecord)
this.fileRecords[index] = {
name: fileRecord.name,
size: fileRecord.size,
type: fileRecord.type,
ext: fileRecord.ext,
progress: 100,
url: backendObj.url
}
}
this.fileRecords = this.fileRecords.slice() // trigger vue change
}, Note that it's still a hack only |
Thanks its too hacky, I will workaround in a different way. I will encaspulate everything in a component with computed get / set to emit the right value to the parent. I would let this ticket open, if you like, to require for a better way to resolve this case, as this is an open issue in a bunch of tickets I saw. I really appreciate this project, its an awesome solution fully of features and looks great... its not easy to find such powerful components in standalone efforts in the Vue ecosystem . |
You can wait for the fix to arrive in few days. Thanks for the appreciation. Thanks for using the library. |
uploaded(event) {
var responses = Array.isArray(event) ? event : [event]
for (var response of responses) {
var respObj = response.data
var backendResponse = respObj.result.files.file[0] //this is the way my backend returns it
var fileRecord = response.fileRecord
fileRecord.url(backendResponse.url)
}
}, |
Hi, after uploading, I need to update the
url
property in the fileRecord object, in order to store in my database the fileRecord with all the information needed to see the files later (as commented in the section "Demo 1. Preloading Existing Files" of the documentation).I try to modify the fileRecord object in this way:
The problem is that after modifying the fileRecord, it's not reflected in the v-model instance (the files have no url set)
I even tried to make something more complex: finding the specific file in the model and updating it manually... but it still doesn't work:
What is the common way of resolving this?
The text was updated successfully, but these errors were encountered: