Fine Uploader file ID is always 0, how to change it? - fine-uploader

I am using Fine Uploader's feature "initial file list". After some initial troubles I am now able to display my files and want to handle the deletion of uploaded items.
According to http://docs.fineuploader.com/branch/master/features/session.html my server-side should provide a JSON array with Objects containing at least name and uuid (I am using the Simple mode of Fine Uploader).
As you can see from the log below, the UUID property is handled without problems, I am receiving it on the server side and deleting the file successfully.
The problem comes from the fact that after a successful deletion I want to do something else on the client side and that is why I listed to the deleteComplete event like this:
.on('deleteComplete', function (event, id, xhr, isError) {
if (!isError) {
console.log("reducing the uploaded items");
.... // do something here
}
Now the id parameter is 0 which is a blocker for me because I have to use it for further processing. I guess the 0 comes from the submitted delete request before.
So what I am looking for is a way to somehow tell Fine Uploader what my id is. I guess if I am able to do it correctly when filling the initial file list then it will be correctly propagated to the deleteComplete method.
Output from Fine Uploader when I load the page with an initial file list and delete one of the files afterwards:
...
"[Fine Uploader 5.1.3] Attempting to update thumbnail based on server response."
"[Fine Uploader 5.1.3] Detected valid file button click event on file '7a5a2ebd-f7d3-40a1-b9da-cde5fc9307c6', ID: 0."
"[Fine Uploader 5.1.3] Submitting delete file request for 0"
"[Fine Uploader 5.1.3] Sending DELETE request for 0"
"[Fine Uploader 5.1.3] Delete request for '7a5a2ebd-f7d3-40a1-b9da-cde5fc9307c6' has succeeded."
....

As seen in the comments, it turned out that the id field is something that Fine Uploader manages internally and manipulating this is not possible and not wanted. As all of my items have their own uuid field I was able to use that one for further processing and distinguishing between the deleted files.
In order to retrieve the uuid field for a provided id one can use the get uuid from an id method which goes like this:
var uuid = $('#fine-uploader').fineUploader('getUuid', id);

Related

Kademi - allow front end user to delete a file they have uploaded

I am trying to allow front end user to delete a file they have uploaded.
#docs() tells me that $page.lead.files has a method called .remove() that accepts either an Int or an Object.
I keep getting a response of "false" when using this method. I am trying to pass and ID or Object of a file within $page.lead.files object.
Debugging...
User: https://spinsurance.admin.kademi.com.au/manageUsers/116783806/#summary-tab
Page: https://crm.spinsurance.co.nz/leads/148615383/
Source: https://spinsurance.admin.kademi.com.au/repositories/spcrm/version1/theme/apps/leadman/components/texteditor?fileName=leadDetailTabContentComponent.html
Under section on page called: Uploaded Files.
Click big red Delete button. (I don't mind if this file gets deleted)
Thanks for your help in advance.
The Lead.files property is a persisted list. Its not a good idea to try to modify the database using that approach.
Note that lead files are exposed as http addressable resources, which support the http DELETE method
So the simplest approach is to delete from the browser using ajax
Eg
DELETE /leads/123/myfile.pdf

Google Apps Script - Query Parameters from opening form passed when submitting form

Current Situation
I have a Web App with an example URL that looks like this
https://script.google.com/a/domain.com/macros/s/Adlksjflf09_LEg8kdlf9/exec?ID=1
This Web App has a doGet(e) function that redirects it to a Google Form URL. Using the example above, it would look like this
https://docs.google.com/forms/d/e/1FAIpQLSfi8jWUK2N4y03N4YYJ9p8Cyr2x06b1C6WgS_TcV98WM_ACtQ/viewform?ID=1
This ID field does not pre-fill any of the questions in the Google Form. Essentially, it's meant to hold information.
When a user submits a form response, I'm combining information from the query parameters as well as the form response and sending it as a payload to a webhook URL.
How I do that is by using CacheService. When a user opens the first URL, the doGet(e) function stores the e.queryString as a Hash in the cache. Then when a user submits the form, I can get the information from the cache and combine it with the formResponse.
The issue I have now is related to concurrency. There will be a case where more than 1 user has opened the first URL. This results in Hash['queryString'] to be overwritten in the cache which is not what I want.
Actual Question
Is there a way to take query parameters from an onFormSubmit from a form and combine it with the form response without using CacheService since my current solution does not support concurrency?
From my understanding, the onFormSubmit trigger doesn't have an e (event variable) for me to do something like a e.queryString to get the query parameters. I may be wrong, need someone to confirm.
OR
Is it possible to cache information in such a way that I can keep track of whose query string is whose and then pull the appropriate information when submitting the form.

Adding custom data based attributes based on Response object

Halo ! I'm trying to implement dropzonejs in a very specific way. Actually I follow the standard implementation described on the official page. Everything works perfectly.
But I'm willing to attach the server's generated URI for each uploaded file directly when uploaded : when uploading it's creating a database entry with some stuff like a page uri with title etc. This mean that the server would return as a response the id of the database saved file in order to attach the href attribute with its value to the the element in front.
This is quite ok to do this when only one file is uploaded, but it becomes trickier when bulk uploading.
So maybe I didn't understand the documentation well (and I'm quite sure I didn't), but is there any way to add custom data-dz-like attributes based on my server's response ? I'd like something like data-dz-url where the url points to a database entity (not the file itself).
Or if not if there is an "easy way" to handle this.
Thanks a lot
Here is the answer :
myDropzone.on('success', (file, response) => {
file.previewElement.href = "/admin/media/"+response.id+"/show/"
})
file is reference to the current uploaded element. It's possible to extend it's html attributes through previewElement. Setting the data-type attribute in the template before, then assigning it the right value works aswell.
Hope this will help some.

Posting a collection to MVC3 from Plupload

I've got a documents upload page in an MVC3 application that lets the user upload documents to be stored in a database and associated with a parent entity in the database. There are also some permissions that the user can customize to stipulate who can access the document.
I've implemented my document upload functionality with Plupload, The behavior that it's working with is that essentially it will take a queue of files, and upload them for me to a specific action dedicated to recieving this information, and when they are posted each file is given a unique name (something like p16kearti61rf31qb61fogjm2127i3.jpg for example.)
Once all of the files have been uploaded in plupload, the parent form is submitted with the information about the files plupload just uploaded as well as some other data for the documents like the Primary Key of the object they are to be associated with, and the groups that have been checked off for it's permissions aspect. Now this works fine except that I can't find a strongly typed object structure that MVC will bind my data to so that I can work with the posted back data. Here's an idea of what is in my Request.Form collection, what I'm looking for is some insight on how to best capture this information in my action. I have complete control over the naming of the controls for the document permissions, but the plupload controls are built in and I'd don't know if I can change them.
__RequestVerificationToken: "...XDsBA5oZA9Ku2oPPdyyi2J+DbvoKRY9HJ2...etc"
ownerId: "CCEE2ADF-633D-4D55-90EE-2829D352BEEB"
uploader_0_tmpname: "p16kearti61rf31qb61fogjm2127i3.jpg"
uploader_0_name: "picture1.jpg"
uploader_0_status: "done"
uploader_1_tmpname: "p16kearti61kqu8tsmja67911v44.jpg"
uploader_1_name: "picture2.jpg"
uploader_1_status: "done"
uploader_2_tmpname: "p16kebp785gci1e291i543cc1c8k4.jpg"
uploader_2_name: "picture3.jpg"
uploader_2_status: "done"
uploader_count: "3"
documentGroups[B8C97C5C-B1B8-43C2-89F1-B1DF353AF677]: "false"
documentGroups[A2C8331C-7068-4611-82BF-6F0C61C8BA7D]: "false"
documentGroups[6DCBF4A8-B863-49E6-AAE9-2A0E372FF622]: "true"
documentGroups[05C04E05-D7A8-45D6-8138-2FA36F0A5922]: "false"
documentGroups[3E2F2B1B-FAAA-420A-B9A1-F223ADF66AF0]: "true"
Any suggestions on how to write my action method? I was hoping for something like this but I can't get it to work.
public ActionResult Upload(Guid ownerId, IList<PluploadFile> uploader, IList<bool> documentGroups)
Just in case someone else was looking for an update on this (and since I got no response to my question what-so-ever), I ended up splitting my post into two; one handled by plUpload which I use to save the file(s) to a temp folder using the unique names pased in to the Action from plUpload (such as p16kearti61rf31qb61fogjm2127i3.jpg), and the other when I post the wrapping form which holds the information I need and the unique names plupload has as well as some fields indicating the status result of the original upload. The problem is that because it's two posts I now have to look at maintaining the contents of my temp folder in case the user uploads documents but doesn't submit the wrapping form. Not the solution I wanted but I can't an alternative working as expected.

How to prevent Alfresco webscript response caching

I have a webscript in alfresco that does something simple: reads a property, and based on its value, creates a json response. Another webscript is in charge of updating this property. However, the response from the original script is sometimes cached, and not for all clients.
So, for one client, I get a current status, and for the other I get the previous state.
The webscript basically reads a property from a node (nodeRef was sent in webscript request):
var status = doc.properties["my:customProp"];
switch (status) {
case "something":
model.prop = "FirstResponse";
break;
case "somethingElse":
model.prop = "SecondResponse";
break;
default:
model.prop = "ThirdResponse";
}
The freemarker template then parses the prop and creates a json output for the response.
Now, this should be simple and straightforward. The use case is as follows:
1. When a user #1 first gets to the doc, the status was set to "something". He got a "FirstResponse", and with a webscript he changed it.
When he then get the document again, he gets the second response.
But if a second client accesses this same node and asks for the response, it still gets the first response, and even more, when I try to read that prop, I get the "old" prop.
So I'm refreshing the script from two clients and reading this property, one client gets one value, the other gets another value.
My only guess (so far) is that this is a caching issue. So, how do I prevent caching? And where did it happen? Hibernate? Some sort of repository cache? How to get rid of it?
check http://wiki.alfresco.com/wiki/Web_Scripts#cache
Well, found the problem here, the prop was defined as d:mltext. So it wasn't cached information, just multilanguage info. I had to extend the model and add a new prop that multilanguage, now all users have the same information.

Resources