DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Because the DevOps movement has redefined engineering responsibilities, SREs now have to become stewards of observability strategy.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Related

  • On-Demand-Schedulers With MuleSoft CloudHub APIs
  • How to Merge HTML Documents in Java
  • Exploring Intercooler.js: Simplify AJAX With HTML Attributes
  • Creating Scrolling Text With HTML, CSS, and JavaScript

Trending

  • Designing AI Multi-Agent Systems in Java
  • Data Lake vs. Warehouse vs. Lakehouse vs. Mart: Choosing the Right Architecture for Your Business
  • Operational Principles, Architecture, Benefits, and Limitations of Artificial Intelligence Large Language Models
  • Endpoint Security Controls: Designing a Secure Endpoint Architecture, Part 2
  1. DZone
  2. Software Design and Architecture
  3. Integration
  4. Loading Files From Web Browser With Mule

Loading Files From Web Browser With Mule

This tutorial explains how to load files from your web browser using Mule 4.

By 
Kasim Bekur user avatar
Kasim Bekur
·
Updated Mar. 10, 20 · Tutorial
Likes (4)
Comment
Save
Tweet
Share
17.8K Views

Join the DZone community and get the full member experience.

Join For Free

Let's learn how to load files from a web browser in Mule 4.



Mule Code:

XML
 




xxxxxxxxxx
1
10


 
1
<flow name="file-uploadFlow">
2
    <http:listener doc:name="Listener" config-ref="HTTP" path="upload-file"></http:listener>
3
    <parse-template location="${apps.home}/web-page/hello.html"></parse>
4
</flow>
5
<flow name="file-uploadFlow1">
6
    <http:listener config-ref="HTTP_Listener_config" path="upload"></http:listener>
7
    <logger level="INFO" doc:name="Logger" message='File content : #[payload."parts"."file"."content"]'></logger>
8
    <set-variable value="Success" variableName="status" ></set>
9
    <parse-template location="${apps.home}/web-page/hello.html"></parse>
10
</flow> 



You might also be interested in: Property File Handling in Mule 4

Note:

  1. Pass  ${apps.home}  in studio VM args or from property files. To run in studio:           -Dapps.home=/Users/<user>/studio/workspace/upload/src/main/resources 
  2.  In the code, payload."parts"."file"."content", the object "file" is from the below HTML input name for file tag. If you change the name in HTML, then the same needs to be used.  <input type="file" required="required" name="file"> 
  3. Instead of using a parse template, we can also use the Load static resources component.

HTML Code:

HTML
 




x
13


 
1
<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
2
    <title>File Upload</title>
3
  </head>
4
  <body>
5
    <div class="container">
6
      <form  method="POST" action="/upload" enctype="multipart/form-data">
7
        <h3>File Upload</h3>
8
        <input type="file" required="required" name="file">
9
        <button type="submit">Submit</button>
10
      </form><br>
11
      <font color="green"> #[if (vars.status != null) 'File upload: ' ++ vars.status else '']</font>
12
    </div> 
13
</body></html>



Note:

  1. Keep this HTML file in <app-name>/src/main/resources/web-page
  2. action="upload" invokes the above Mule flows 

Further Reading

Mule: Load Properties as per the Environment (With Default Properties File)

HTML MULE

Opinions expressed by DZone contributors are their own.

Related

  • On-Demand-Schedulers With MuleSoft CloudHub APIs
  • How to Merge HTML Documents in Java
  • Exploring Intercooler.js: Simplify AJAX With HTML Attributes
  • Creating Scrolling Text With HTML, CSS, and JavaScript

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!