Project

General

Profile

« Previous | Next » 

Revision 9094

Updated D1ResourceHandler to not hardcode a file size limit. This will allow
large, multi-gigabyte files to be uploaded, but still needs testing. The limit
is now drawn from the metacat.properties file. An alternative would be to inspect
the Content-Length header of the request and set the max to a value greater than the
request size, but this would allow arbitrarily sized uploads. Warrants discussion.

View differences:

lib/metacat.properties
594 594
# Default checksum algorithm
595 595
dataone.checksumAlgorithm.default=MD5
596 596

  
597
# Default file upload size for create() and update (in bytes)
598
dataone.max_upload_size=10000000000
599

  
597 600
# overall services (TODO: mn vs. cn?)
598 601
dataone.mn.services.enabled=true
599 602
dataone.mn.registration.submitted=false
src/edu/ucsb/nceas/metacat/restservice/D1ResourceHandler.java
81 81
    /**HTTP Verb HEAD*/
82 82
    public static final byte HEAD = 5;
83 83

  
84
	/** Maximum size of uploads, defaults to 1GB if not set in property file */
85
	private static int MAX_UPLOAD_SIZE = 1000000000;	
86

  
84 87
    /*
85 88
     * API Resources
86 89
     */
......
120 123
        this.servletContext = servletContext;
121 124
        this.request = request;
122 125
        this.response = response;
126
        logMetacat = Logger.getLogger(D1ResourceHandler.class);
127
		try {
128
			MAX_UPLOAD_SIZE = Integer.parseInt(PropertyService.getProperty("dataone.max_upload_size"));
129
		} catch (PropertyNotFoundException e) {
130
			// Just use our default as no max size is set in the properties file
131
			logMetacat.warn("Property not found: " + "dataone.max_upload_size");
132
		}
133

  
123 134
    }
124 135

  
125 136
    /**
......
256 267

  
257 268
        // handle MMP inputs
258 269
        MultipartRequestResolver mrr = 
259
            new MultipartRequestResolver(tmpDir.getAbsolutePath(),1000000000, 0);
270
            new MultipartRequestResolver(tmpDir.getAbsolutePath(), MAX_UPLOAD_SIZE, 0);
260 271

  
261 272
        mr = mrr.resolveMultipart(request);
262 273
        logMetacat.debug("Resolved the rights holder info from the mime multipart entity.");
......
274 285
     */
275 286
    protected Map<String, File> collectMultipartFiles() 
276 287
        throws ServiceFailure, InvalidRequest {
277
    	
288
   
278 289
        // Read the incoming data from its Mime Multipart encoding
279 290
        logMetacat.debug("Disassembling MIME multipart form");
280 291
        
......
282 293
        File tmpDir = getTempDirectory();
283 294
        logMetacat.debug("temp dir: " + tmpDir.getAbsolutePath());
284 295
        MultipartRequestResolver mrr = 
285
        	new MultipartRequestResolver(tmpDir.getAbsolutePath(), 1000000000, 0);
296
        	new MultipartRequestResolver(tmpDir.getAbsolutePath(),  MAX_UPLOAD_SIZE, 0);
286 297
        MultipartRequest mr = null;
287 298
		    try {
288 299
		    	  mr = mrr.resolveMultipart(request);
......
366 377
		File tmpDir = getTempDirectory();
367 378
		logMetacat.debug("temp dir: " + tmpDir.getAbsolutePath());
368 379
		MultipartRequestResolver mrr = 
369
			new MultipartRequestResolver(tmpDir.getAbsolutePath(), 1000000000, 0);
380
			new MultipartRequestResolver(tmpDir.getAbsolutePath(),  MAX_UPLOAD_SIZE, 0);
370 381
		MultipartRequest mr = mrr.resolveMultipart(request);
371 382
		
372 383
		multipartparams = mr.getMultipartParameters();

Also available in: Unified diff