Upload File with DoclibAction

cancel
Showing results for 
Search instead for 
Did you mean: 
David76
Member II

Upload File with DoclibAction

Jump to solution

Hi Everyone !

I work with this alfresco version : All-In-One (AIO) project for SDK 4.0
I would like to upload a file with DocLibAction but in Java part, I receive this value : {pdf-document-upload=C:\fakepath\pom.xml}

add-doclib-actions-extension-modules.xml
========================================

<config evaluator="string-compare" condition="upload-pdf">
	<forms>
		<form>
			<field-visibility>
				<show id="pdf-document-upload" />
			</field-visibility>
			<appearance>
				<field id="pdf-document-upload" label-id="com.assystem.doclib.action.uploadPDF.form.field.pdf-document-upload">
					<constraint-handlers>
						<constraint type="MANDATORY" validation-handler="Alfresco.forms.validation.mandatory" event="blur" />
					</constraint-handlers>
					<control template="/com/assystem/form/controls/uploadpdf.ftl" />
				</field>
			</appearance>
		</form>
	</forms>
</config>

uploadpdf.ftl
=========================================

<div class="form-field">
	<label>Upload PDF:</label>
	<input type="file" multiple="" name="prop_pdf-document-upload" />
</div>


UploadPDFExecuter.java
==========================================

public class UpdateLivrablePDFExecuter extends ActionExecuterAbstractBase {

public static final String PARAM_PDF_DOCUMENT_UPLOAD = "pdf-document-upload";

private ServiceRegistry serviceRegistry;


@Override
protected void executeImpl(Action action, NodeRef actionedUponNodeRef) {

// Result of uploadFile : {uploadFile=C:\fakepath\pom.xml}
Serializable uploadFile = (Serializable) action.getParameterValue(PARAM_PDF_DOCUMENT_UPLOAD);

How can i have my document in uploadFile ? (instead of uploadFile=C:\fakepath\pom.xml)


Thank you for yours answers !

1 Solution

Accepted Solutions
afaust
Master

Re: Upload File with DoclibAction

Jump to solution

The Forms framework is not designed to handle file uploads at all - both on the client and the server-side. So there is no way to support this unless you use some custom dialog handling code on the client (which may still use the form definition to render the form UI) which calls a custom web script endpoint to accept the parameters, including the file upload, which also requires some custom submit handling code to properly transfer to that endpoint.

View solution in original post

1 Reply
afaust
Master

Re: Upload File with DoclibAction

Jump to solution

The Forms framework is not designed to handle file uploads at all - both on the client and the server-side. So there is no way to support this unless you use some custom dialog handling code on the client (which may still use the form definition to render the form UI) which calls a custom web script endpoint to accept the parameters, including the file upload, which also requires some custom submit handling code to properly transfer to that endpoint.

View solution in original post