How to set content-length-range in FineUploader S3? - fine-uploader

When content-length-range is set by validation, it results in files greater than that size not being able to be added to the uploader at all:
validation: {
sizeLimit: 1048576
},
How can I just set content-length-range without any other bells/whistles?

The simplest solution would be to leave the validation.sizeLimit option alone in this case and set a properly formatted content-length-range parameter via the request.params option. Fine Uploader S3 will include these params in the policy document (if a policy document is used). Another option would be to maintain two separate Fine Uploader instances. One instance accepts files from the user w/out validation. That instance is also used to scale images, which are then passed into the "main" Fine Uploader S3 instance via the addFiles API method. This "main" instance has validation set.

Related

How to use user data in typo3 flux template without caching it

I try to get user session data in a typo3 flux content element. with {user.first_name} I can access the first name of the user, but this will get cached, meaning alls users will see the name of the first one accessing the page. How can I uncache that or load user session data in this template.
What I already tried:
<f:cache.disable> </f:cache.disable> unfortunately the user variable
are still cached...
<v:render.uncache> To make the user session data
accessible in the partial I need to pass it as a parameter, but the
parameters do get cached :(
<f:security.ifAuthenticated> does only
check for permission, but caches aswell.
Working methods:
adding config.no_cache = 1 or page.config.no_cache = 1 in the typoscript setup works, but I would like to use a solution in flux without typoscript, the USER_INT equival solution should be v:render.uncache, but the argument to be passed is cached as explained above
Thanks for any help
You have to use <v:render.uncache> and fetch the user session data inside the partial.
See https://github.com/FluidTYPO3/vhs/issues/1705

How to handle image tag in Rich Text field in Sitecore, so that it can handle the media hash automatically?

My Sitecore website is on 7.5. I have implemented a media protection request feature, but I can see too many errors in Sitecore logs saying that:
ERROR MediaRequestProtection: An invalid/missing hash value was
encountered. The expected hash value: Media URL: , Referring URL:
My question is How to handle an image tag in Rich Text field in Sitecore, so that it can handle the media hash automatically?
Since version 7.5 Sitecore introduced a Media Request Protection which is a hash added to assets' URLs. I think that this was a good thing to avoid any kind of denial of service attacks.
On every incoming media request Sitecore calculates the hash of the request query string parameters and compares it with the given hash. If they are equal then Sitecore will perform the needed routine based on the provided URL parameters (for example, image resizing), but if they are not equal then Sitecore will throw a MediaRequestProtection error and send the original file as is.
There is a known issue in Sitecore Rich Text Editor (RTE) with 438674 Ticket Id and "Media request protection is not applied to media in a hyperlink within the RTE" description. Sitecore Support can provide a patch to override the method for rendering media links from RTE fields to also include the hash value. See the reference under Sitecore 8.2 release notes here.
If you don't have any Sitecore Support coverage by now then you can implement a workaround as follows:
Hook into saveRichTextContent pipeline to alter the RTE content before saving. For items that haven’t been modified after the saveRichTextContent pipeline has been introduced you can create a new renderField pipeline for Rich Text field type, but I would rather recommend to stick to saveRichTextContent pipeline approach and simply re-save all items with RTEs containing media assets.
Write your custom code to loop through images within the RTE HTML and modify the image rendering accordingly. Note, that you need to use Sitecore.Resources.Media.HashingUtils.ProtectAssetUrl() method to generate the full URL with the hash added, for example:
string mediaUrl = Sitecore.Resources.Media.MediaManager.GetMediaUrl(yourMediaItem);
string safeMediaUrl = Sitecore.Resources.Media.HashingUtils.ProtectAssetUrl(mediaUrl);

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

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

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);

How to get all posted files at once using fineUploader?

I have a fineuploader that allows multiple files to be uploaded in MVC web app.
Example:
Suppose I upload 3 files 5MB, 20MB, 1MB
I expect 3 files to arrive in the controller in single call but they are not.
I want to iterate all 3 files (array) and process
Question 1: Is there a way to get all 3 files at once in the server?
[HttpPost]
public FineUploaderResult UploadFile(FineUpload upload)
{
//upload contains only one file at a time
//for second file it gets call again even though I submit only once
}
No. Fine Uploader sends each file in a separate request. This is not currently configurable. If you need to tie your files together, you can easily do that by passing common parameters with each file via the params option, or the setParams API method. Sever-side, you can look for this common parameter in each upload POST request and deal with the files accordingly.

Resources