In my Grails app, I have an action that has an uploaded file parameter. The file is retrieved from the request like so:
CommonsMultipartFile cu = params['currencyResult']
It works fine if the file size is small, but if I try and upload a 1.3MB file, a "connection was reset" error occurs (execution never reaches the action).
I've tried making the following changes to allow files up to 100MB to be uploaded. In resources.groovy, I added the following Spring bean
multipartResolver(CommonsMultipartResolver) {
maxUploadSize = 1000000 * 100 // 100 MB
}
In Tomcat's server.xml, I added this maxPostSize attribute to the Connector
<Connector port="80" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="443" maxPostSize="100000000"/>
But still the upload fails for a 1.3MB file. Is there something else I need to configure in order to allow larger files to be uploaded?
Have you looked into setting Tomcat's connectionUploadTimeout and disableUploadTimeout?
From the Documentation:
connectionUploadTimeout
Specifies the timeout, in milliseconds, to use while a data upload is
in progress. This only takes effect if disableUploadTimeout is set to
false.
Example:
<Connector port="80" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="443"
maxPostSize="100000000"
disableUploadTimeout="false"
connectionUploadTimeout="300000" />
Or in development, you can set this in Grails with the following:
eventConfigureTomcat = { tomcat ->
tomcat.connector.setAttribute('disableUploadTimeout', false);
tomcat.connector.setAttribute('connectionUploadTimeout', 300000);
}
You will want to adjust the timeout value according to your needs.
Are you doing this by a WS or POST?
if with WS adjust the
<scripting>
<webServices>
<jsonSerialization maxJsonLength="500000000"/>
</webServices>
</scripting>
Related
I have a Cordova app (built on Ember.js, using the Corber addon) that I am currently only running on iOS, specifically the iOS simulator (iPhone 8, iOS v12), so it is using a WKWEBVIEW.
The app is using cordova's file plugins to download remote images and store them on the user's device, currently in the "Documents" (cordova.file.documentsDirectory), which works fine, and I've verified that the images do in fact exist there. However I can't figure out the correct URL/URI to use to display those images in the app via standard <img> tags.
Cordova's own documentation says to use the cdvfile:// protocol path (https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-file/#cdvfile-protocol), but even with following the instructions there (adding the content-security meta tag to the index.html, the access rule to the config.xml, etc), it seems like WKWEBVIEW just flat out does not support this protocol, giving me "unsupported URL" errors in the console when I attempt to use it.
Other SO answers on the subject suggest using a normal URL path relative to the cordova app's web server URL, e.g. things like <img src="/Library/NoCloud/path-to-my/file.jpg"> but any path I try 404's.
This seems like such a simple/common use case, but I'm stumped.
For anyone else struggling as I was - there is also a solution, which requires no significant change to the code which I found after hopeless days when no solution seemed available
There are 2 steps required:
First update your config.xml with following
<platform name="ios">
<preference name="scheme" value="app" />
<preference name="hostname" value="localhost" />
</platform>
Then convert your file:// link by using the undocumented method
window.WkWebView.convertFilePath(filePath)
This method performs the conversion into a virtual localhost link that makes the file accessible and bypasses the WkWebView restrictions. A little bit longer sample goes like this
let localFile = cordova.file.dataDirectory + 'logo.png';
let convertedPath = window.WkWebView.convertFilePath(localFile);
document.getElementById("myImg").src = convertedPath;
I did not work with Cordova but docs you linked say this:
To use cdvfile as a tag' src you can convert it to native path via toURL() method of the resolved fileEntry, which you can get via resolveLocalFileSystemURL - see examples below.
And gives this as an example:
resolveLocalFileSystemURL('cdvfile://localhost/temporary/path/to/file.mp4', function(entry) {
var nativePath = entry.toURL();
console.log('Native URI: ' + nativePath);
document.getElementById('video').src = nativePath;
Given all that, I would say that you can try to create a component, cdv-img. Something like this supposed to work, I think:
import Component from '#ember/component';
export default Component.extend({
tagName: 'img',
cdvPath: undefined,
didReceiveAttrs() {
this._super(...arguments);
if (this.cdvPath) {
resolveLocalFileSystemURL(this.cdvPath, (entry) => {
this.$().attr('src', entry.toURL());
});
}
},
});
Use it like this:
{{cdv-img cdvPath='cdvfile://localhost/temporary/path/to/file.jpg'}}
UPD
If it does not work with file protocol, you can try to convert image to data url
import Component from '#ember/component';
export default Component.extend({
tagName: 'img',
cdvPath: undefined,
didReceiveAttrs() {
this._super(...arguments);
if (this.cdvPath) {
const el = this.$();
resolveLocalFileSystemURL(this.cdvPath, (entry) => {
entry.file(function (file) {
const reader = new FileReader();
reader.onloadend = function() {
el.attr('src', this.result);
};
reader.readAsDataURL(file);
});
});
}
},
});
Make sure you don't forget to add these 2 lines and try with whatever solution you are trying, I got my images shown after adding them:
In your config.xml file. add:
<preference name="allowFileAccessFromFileURLs" value="true" />
<preference name="allowUniversalAccessFromFileURLs" value="true" />
For several years on our THREDDS Data Server (TDS) we've been happily using the cache="false" functionality on datasetRoot to tell the TDS not to cache several netcdf files.
<service name="allServices" serviceType="Compound" base="">
<service name="ncdods" serviceType="OpenDAP" base="/thredds/dodsC/"/>
<service name="HTTPServer" serviceType="HTTPServer" base="/thredds/fileServer/"/>
<service name="iso" serviceType="ISO" base="/thredds/iso/"/>
<service name="uddc" serviceType="UDDC" base="/thredds/uddc/"/>
</service>
<datasetRoot path="FVCOM" location="/http/www/CODFISH/Data/FVCOM/" cache="false"/>
<dataset name="NECOFS GOM2 Forecast" ID="gom2_nocache" serviceName="allServices"
urlPath="FVCOM/NECOFS/Forecasts/NECOFS_GOM2_FORECAST.nc" dataType="Grid"/>
The reason we don't want to ever cache these files is that every day these daily forecast files get overwritten with files that have the same name, but different data.
But now we have a need to add and modify the attributes of these datasets. In particular, we would like to add the global attribute
<attribute name="cdm_data_type" value="any"/>
Can we modify attributes via NcML when the dataset to be modified is contained in this kind of datasetRoot construct?
Could someone please help me to solve my problem?
I'm using ASPX files on IIS 7.5 and URL-Rewrite 2.0 to get SSL in any access condition:
www.somedomain.com -> https://www.somedomain.com
www.somedomain.com/mypage.aspx -> https://www.somedomain.com/mypage.aspx
It's functioning perfectly. BUT, since the page loads/plays some MP3/OGG files, I had noticed that:
1- if the page is executed in SSL, the MP3 does not play in some devices (Androids/iPhone/iPad mobile devices);
2- if the page is executed WITHOUT SSL, it occurrs normally, 100%.
So, I had tried to filter the MP3/OGG files (and also, PNG/JPG images) in URL-REWRITE to avoid their access under SSL.
My filter is:
<add input="{REQUEST_URI}" pattern="(png|jpg|mp3|ogg)" negate="true" />
<add input="{HTTPS}" pattern="^OFF$" />
I had tried a lot of filter settings on these files, as {REQUEST_URI}, {URL}, {UNENCODED_URL} and I see that all of them are ineffective to avoid these files under SSL. I see this using MICROSOFT NETWORK MONITOR, that shows all files being loaded in port 443 (HTTPS). Another characteristic is the fact of I never see the original filenames there (the MP3 files and images). It seems everything is under SSL settings. Another one is the fact of the MP3 does not play in SSL access and the images delay some seconds to load.
I CANNOT utilize the whole domain/folder name (like www.mydomain.com/songs/music.MP3) since I'm using JPLAYER 2.0 and I cannot set this library with the entire MP3 address (the song does not play!), but just the subfolder where they remain, like below (see mp3 and ogg tags):
$("#jquery_jplayer_1").jPlayer({
ready: function () {
$(this).jPlayer("setMedia", {
mp3:"audio/" + theSongs[0] + ".mp3",
ogg:"audio/" + theSongs[0] + ".ogg"
});
},
play: function () { // To avoid both jPlayers playing together.
$(this).jPlayer("pauseOthers");
},
swfPath: "Scripts/jPlayer/",
supplied: "mp3, ogg",
volume: 0.25,
cssSelectorAncestor: "#jp_container_1",
wmode: "window"
});
How to avoid this kind of behavior? I wouldn't like to put these files (MP3, OGG, JPG, PNG) in another domain to avoid URL-REWRITE to catch them. I need them in the same main project and within one of its subfolder (audio and images folders).
How to create an inbound rule to REALLY discard completely these files?
Note: if I utilize as a rule something like
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
it doesn't play (or loads) too.
I would appreciate a lot your efforts to help me in solving that problem.
Kind regards,
David
I'm using the ImageResizer module in an ASP.NET MVC 4 project, along with the plugins SqlReader and MvcRoutingShim.
When I try to access the URL ~/databaseimages/123.jpg (for example), I just get the standard error 404 - The resource cannot be found.
My expectation was that ImageResizer would handle that request and try to read the image from the database, but it doesn't even try to connect (I used SQL Profiler to verify this).
What can be wrong?
This is the output of /resizer.debug:
Image resizer diagnostic sheet 26-06-2012 20:42:57
1 Issues detected:
(Warning): To potentially see additional errors here, perform an image resize request.
You are using paid bundles: Cloud Bundle, Performance Bundle
Registered plugins:
ImageResizer.Plugins.Basic.DefaultEncoder
ImageResizer.Plugins.Basic.NoCache
ImageResizer.Plugins.Basic.ClientCache
ImageResizer.Plugins.Basic.Diagnostic
ImageResizer.Plugins.Basic.SizeLimiting
ImageResizer.Plugins.MvcRoutingShim.MvcRoutingShimPlugin
ImageResizer.Plugins.SqlReader.SqlReaderPlugin
ImageResizer.Plugins.DiskCache.DiskCache
Configuration:
<resizer>
<plugins>
<add name="MvcRoutingShim" />
<add name="SqlReader" prefix="~/databaseimages/" connectionString="database" idType="UniqueIdentifier" blobQuery="SELECT Content FROM Images WHERE ImageID=#id" modifiedQuery="Select ModifiedDate, CreatedDate From Images WHERE ImageID=#id" existsQuery="Select COUNT(ImageID) From Images WHERE ImageID=#id" requireImageExtension="false" cacheUnmodifiedFiles="true" extensionPartOfId="false" vpp="true" untrustedData="false" />
<add name="DiskCache" />
</plugins>
</resizer>
(...)
In your Web.config file, you declared that image IDs are all GUIDs: idType="UniqueIdentifier", yet used a integer in the url: localhost:50272/databaseimages/123.jpg.
<add name="SqlReader" prefix="~/databaseimages/" connectionString="database"
idType="UniqueIdentifier" requireImageExtension="false"
cacheUnmodifiedFiles="true" extensionPartOfId="false"
vpp="true" untrustedData="false" />
If you're not specifying a GUID in the URL, the request will be ignored. Change idType to a different data type, like Int, or use the correct data type in the URL.
Source: http://imageresizing.net/plugins/sqlreader
Currently we need fetch mails from an IMAP server using Mule ESB. Once the mails have been fetched, we only need the attachments and save them on the harddrive. So far so good. Now I got a couple of questions:
How do I keep the original name intact using a file:outbound-endpoint?
How can I check how many attachments I got?
How do save a copy of the mail on the IMAP and local drive?
#1: I tried #header:fileName or #originalFileName or even removing the outputpattern (this results in the filename being "35c7dea0-519a-11e1-b8b2-092b658ae008.dat")
#2: I am trying to make a flow where I check how many attachments there are. If there are less then 1 then I want to save the files and no further process them. If it's more then 1, then save it and process it. I tried COUNT but it didn't work.
#3: am trying to MOVE a message when READ to a back-up folder on the IMAP-server. On top of that I'll save a copy on the local server. Problem is that with the current code, the message does not get marked as read nor moved. The messages stay unread and they get copied (over and over, enldess loop) instead of getting moved to the IMAP back-up folder. When enabling the deleteReadMessages then the loop is broken but the message does not get copied on the IMAP.
Here's the code I am currently using:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:imap="http://www.mulesoft.org/schema/mule/imap"
xmlns:file="http://www.mulesoft.org/schema/mule/file"
xmlns:email="http://www.mulesoft.org/schema/mule/email"
xmlns:vm="http://www.mulesoft.org/schema/mule/vm"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.2/mule.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/3.2/mule-file.xsd
http://www.mulesoft.org/schema/mule/imap http://www.mulesoft.org/schema/mule/imap/3.2/mule-imap.xsd
http://www.mulesoft.org/schema/mule/email http://www.mulesoft.org/schema/mule/email/3.2/mule-email.xsd
http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/3.2/mule-vm.xsd">
<imap:connector name="imapConnector" checkFrequency="5000"
backupEnabled="true" backupFolder="/home/mark/workspace/Eclipse/RHZ_Project/src/Archive/"
mailboxFolder="INBOX" moveToFolder="INBOX.Backup" deleteReadMessages="false"
defaultProcessMessageAction="SEEN" />
<expression-transformer name="returnAttachments">
<return-argument evaluator="attachments-list" expression="*.txt,*.ozb,*.xml" optional="false"/>
</expression-transformer>
<flow name="Flow1_IMAP_fetch">
<imap:inbound-endpoint user="USER" password="PASS" host="IP"
port="143" transformer-refs="returnAttachments" disableTransportTransformer="true"/>
<collection-splitter/>
<file:outbound-endpoint path="/home/mark/workspace/Eclipse/RHZ_Project/src/Inbox/#[function:datestamp].dat">
<expression-transformer>
<return-argument expression="payload.inputStream" evaluator="groovy" />
</expression-transformer>
</file:outbound-endpoint>
</flow>
</mule>
1) How do I keep the original name intact using a file:outbound-endpoint?
Attachments are javax.activation.DataHandler instances so you should be able to call getName() on them, with an OGNL or Groovy expression. For example:
#[groovy:payload.name]
Should give you the original attachment name.
2) How can I check how many attachments I got?
Before the splitter, use a choice router and an condition that checks the size() attribute of the attachment list, like:
#[groovy:payload.size()>1]
3) How do save a copy of the mail on the IMAP and local drive?
I do not know what the issue is here. Maybe marking as seen is not supported. Or maybe the fact that you disable the transport transformer prevents a post-read action to kick in.
By the way, I suggest you leave the default transport transformer as-is and move the returnAttachments transformer after the inbound endpoint, before the splitter.