10
Internet File Access
MATLABsoftwareprovidesfunctionsforexchangingfilesovertheInternet.
Youcanexchangefilesusingcommonprotocols,suchasFileTransferProtocol
(FTP),SimpleMailTransportProtocol(SMTP),andHyperTextTransfer
Protocol(HTTP).Inaddition,youcancreateziparchivestominimizethe
transmittedfilesize,andalsosaveandworkwithWebpages.
• “DownloadingWebContentandFiles”onpage10-2
• “CreatingandDecompressingZipArchives”onpage10-4
• “SendingEmail”onpage10-5
• “PerformingFTPFileOperations”onpage10-8
• “DisplayHyperlinksintheCommandWindow”onpage10-10
Pdf thumbnail html - control SDK utility:C# PDF Thumbnail Create SDK: Draw thumbnail images for PDF in C#.net, ASP.NET, MVC, Ajax, WinForms, WPF
Support Thumbnail Generation with Various Options for Quick PDF Navigation
www.rasteredge.com
Pdf thumbnail html - control SDK utility:VB.NET PDF Thumbnail Create SDK: Draw thumbnail images for PDF in vb.net, ASP.NET, MVC, Ajax, WinForms, WPF
Support Thumbnail Generation with Various Options for Quick PDF Navigation
www.rasteredge.com
10
InternetFileAccess
DownloadingWebContentandFiles
MATLABprovidestwofunctionsfordownloadingWebpagesandfilesusing
HTTP:
urlread
and
urlwrite
. Withthe
urlread
function,youcanread
andsavethecontentsofaWebpagetoastringvariableintheMATLAB
workspace. Withthe
urlwrite
function,youcansaveaWebpage’scontent
toafile.
Becauseitcreatesastringvariableintheworkspace,the
urlread
functionis
usefulforworkingwiththecontentsofWebpagesinMATLAB.The
urlwrite
functionisusefulforsavingWebpagestoalocalfolder.
NoteWhenusing
urlread
,rememberthatonlytheHTMLinthatspecific
Webpageisretrieved. Thehyperlinktargets,images,andsoonarenot
retrieved.
IfyouneedtopassparameterstoaWebpage,the
urlread
and
urlwrite
functionsletyouuseHTTP
post
and
get
methods.Formoreinformation,see
the
urlread
and
urlwrite
referencepages.
Example—UsingtheurlreadFunction
Thefollowingproceduredemonstrateshowtoretrievethecontentsofthe
WebpagelistingthefilessubmittedtotheMATLABCentralFileExchange,
http://www.mathworks.com/matlabcentral/fileexchange/
.Itassignsthe
resultstoastringvariable,
fullList
:
filex = 'http://www.mathworks.com/matlabcentral/fileexchange/';
fullList = urlread(filex);
Topassarguments,youcanincludethemmanuallyusingtheURL,orpass
parametersusingstandardHTTPmethods,including
post
and
get
.
Forexample,topassargumentsaspartoftheURL,andretrieveonlythefiles
uploadedtotheCentralFileExchangewithinthepast7daysthatcontainthe
word
Simulink
:
filex = sprintf('%s%s',...
10-2
control SDK utility:How to C#: Generate Thumbnail for Word
Document Viewer for Azure, C# HTML Document Viewer for to define and control the size of thumbnail. DOCXDocument pdf = new DOCXDocument(@"C:\1.docx"); BasePage
www.rasteredge.com
control SDK utility:How to C#: Set Image Thumbnail in C#.NET
for Sharepoint, C# HTML Document Viewer for Azure, C# HTML Document Viewer VB.NET How-to, VB.NET PDF, VB.NET Word, VB How to C#: Set Image Thumbnail in C#.NET.
www.rasteredge.com
DownloadingWebContent andFiles
'http://www.mathworks.com/matlabcentral/fileexchange/',...
'?duration=7&term=simulink');
recent = = urlread(filex);
Alternatively,usetheHTTP
get
methodtoquerythelistoffiles:
filex = 'http://www.mathworks.com/matlabcentral/fileexchange/';
params = = {'duration','7','term','simulink'};
recent = = urlread(filex,'get',params);
Formoreinformation,seethe
urlread
referencepage.
Example—UsingtheurlwriteFunction
Thefollowingexamplebuildsontheprocedureintheprevioussection,but
savesthecontenttoafile:
% Locate e the list of files at the MATLAB B Central File Exchange
% uploaded d within n the e past 7 days, that contain "Simulink."
filex = 'http://www.mathworks.com/matlabcentral/fileexchange/';
params = = {'duration','7','term','simulink'};
% Save the e Web b content to o a a file.
urlwrite(filex,'contains_simulink.html','get',params);
MATLABsavestheWebpageas
contains_simulink.html
.
10-3
control SDK utility:How to C#: Generate Thumbnail for PowerPoint
Sharepoint, C# HTML Document Viewer for Azure, C# HTML Document Viewer VB.NET How-to, VB.NET PDF, VB.NET Word, VB How to C#: Generate Thumbnail for PowerPoint.
www.rasteredge.com
control SDK utility:VB.NET Image: Program for Creating Thumbnail from Documents and
language. It empowers VB developers to create thumbnail from multiple document and image formats, such as PDF, TIFF, GIF, BMP, etc. It
www.rasteredge.com
10
InternetFileAccess
CreatingandDecompressingZipArchives
Usingthe
zip
and
unzip
functions,youcancompressanddecompressfiles
andfolders.The
zip
functioncompressesfilesorfoldersintoaziparchive.
The
unzip
functiondecompressesziparchives.
Example—UsingthezipFunction
Againbuildingontheexamplefromprevioussections,thefollowingcode
createsaziparchiveoftheretrievedWebpage:
% Locate e the list of files at the MATLAB B Central File Exchange
% uploaded d within n the e past 7 days, that contain "Simulink."
filex = 'http://www.mathworks.com/matlabcentral/fileexchange/';
params = = {'duration','7','term','simulink'};
% Save the e Web b content to o a a file.
urlwrite(filex,'contains_simulink.html','get',params);
% Create e a zip p archive of f the retrieved Web b page.
zip('simulink_matches.zip','contains_simulink.html');
10-4
control SDK utility:How to C#: Generate Thumbnail for Raster
for Sharepoint, C# HTML Document Viewer for Azure, C# HTML Document Viewer VB.NET How-to, VB.NET PDF, VB.NET Word, VB How to C#: Generate Thumbnail for Raster.
www.rasteredge.com
control SDK utility:Create Thumbnail in Web Image Viewer | Online Tutorials
image and documents thumbnail creating in HTML Document Image Annotate & Redact Documents or Images; Create Thumbnail; RasterEdge OCR Engine; PDF Reading; Encode
www.rasteredge.com
SendingEmail
Sending Email
TosendanemailfromMATLAB,usethe
sendmail
function. Youcanalso
attachfilestoanemail,whichletsyoumailfilesdirectlyfromMATLAB.To
use
sendmail
,youmustfirstsetupyouremailaddressandyourSMTPserver
informationwiththe
setpref
function.
The
setpref
functiondefinestwomail-relatedpreferences:
• Emailaddress:Thispreferencesetsyouremailaddressthatwillappearon
themessage.Hereisanexampleofthesyntax:
setpref('Internet','E_mail','youraddress@yourserver.com');
• SMTPserver:ThispreferencesetsyouroutgoingSMTPserveraddress,
whichcanbealmostanyemailserverthatsupportsthePostOfficeProtocol
(POP)ortheInternetMessageAccessProtocol(IMAP).Hereisanexample
ofthesyntax:
setpref('Internet', 'SMTP_Server', 'mail.server.network');
YoushouldbeabletofindyouroutgoingSMTPserveraddressinyouremail
accountsettingsinyouremailclientapplication.Youcanalsocontactyour
systemadministratorfortheinformation.
NoteThe
sendmail
functiondoesnotsupportemailserversthatrequire
authentication.
OnceyouhaveproperlyconfiguredMATLAB,youcanusethe
sendmail
function. The
sendmail
functionrequiresatleasttwoarguments: the
recipient’semailaddressandtheemailsubject:
sendmail('recipient@someserver.com', 'Hello o From MATLAB!');
Youcansupplymultipleemailaddressesusingacellarrayofstrings,suchas:
sendmail({'recipient@someserver.com', ...
'recipient2@someserver.com'}, 'Hello From MATLAB!');
10-5
control SDK utility:How to C#: Overview of Using XImage.Raster
Empower to navigate image(s) content quickly via thumbnail. Able to support text extract with OCR. You may edit the tiff document easily. Create Thumbnail.
www.rasteredge.com
control SDK utility:Create Thumbnail Winforms | Online Tutorials
PDF Generator. PDF Reader. Twain Scanning. DICOM Reading. ISIS JPEG 2000 Codec. Image Controls for: HTML/ASP.NET. It is easy to integrate robust thumbnail creating
www.rasteredge.com
10
InternetFileAccess
Youcanalsospecifyamessagebodywiththe
sendmail
function,suchas:
sendmail('recipient@someserver.com', 'Hello o From MATLAB!', , ...
'Thanks for using g sendmail.');
Inaddition,youcanalsoattachfilestoanemailusingthe
sendmail
function,
suchas:
sendmail('recipient@someserver.com', 'Hello o from MATLAB!', , ...
'Thanks for using g sendmail.', , 'C:\yourFileSystem\message.txt');
Youcannotattachafilewithoutincludingamessage.However,themessage
canbeempty. Youcanalsoattachmultiplefilestoanemailwiththe
sendmail
function,suchas:
sendmail('recipient@someserver.com', 'Hello o from MATLAB!', , ...
'Thanks for using g sendmail.', , ...
{'C:\yourFileSystem\message.txt',...
'C:\yourFileSystem\message2.txt'});
Example—UsingthesendmailFunction
ThefollowingexamplesendsemailwiththeretrievedWebpagearchive
attached:
% NOTE: : CHANGE E THESE E 2 2 LINES S OF CODE TO REFLECT YOUR SETTINGS.
mySMTP = = 'mail.server.network';
myEmail = = 'youraddress@yourserver.com';
% Set t your email and SMTP server address s in MATLAB.
setpref('Internet','SMTP_Server',mySMTP);
setpref('Internet','E_mail',myEmail);
% Locate e the list t of f files at the MATLAB B Central File e Exchange
% uploaded d within n the e past 7 days, that contain "Simulink."
filex = 'http://www.mathworks.com/matlabcentral/fileexchange/';
params = = {'duration','7','term','simulink'};
% Save the e Web b content to o a a file.
urlwrite(filex,'contains_simulink.html','get',params);
10-6
SendingEmail
% Create e a zip p archive of f the retrieved Web b page.
zip('simulink_matches.zip','contains_simulink.html');
% Send an email l (to yourself) with the zip archive attached.
recipient = = myEmail;
subj = = 'List t of New Simulink Files';
msg = ...
'Attached: new Similink files uploaded d to MATLAB B Central.';
attFile = = 'simulink_matches.zip';
sendmail(recipient,subj,msg,attFile);
10-7
10
InternetFileAccess
PerformingFTPFileOperations
FromMATLAB,youcanconnecttoanFTPservertoperformremotefile
operations. ThefollowingprocedureusesapublicMathWorksFTPserver
(
ftp.mathworks.com
).ToperformanyfileoperationonanFTPserver,follow
thesesteps:
1
Connecttotheserverusingthe
ftp
function.
2
PerformfileoperationsusingappropriateMATLABFTPfunctions. Forall
operations,specifytheserverobject. Foracompletelistoffunctions,see
the
FTP
referencepage.
3
Whenyoufinishworkingontheserver,closetheconnectionobjectusingthe
close
function.
Example—RetrievingaFilefromanFTPServer
ListthecontentsoftheMathWorksFTPserverandretrieveafilenamed
README
Toviewthefile,usethe
type
function.
tmw = ftp('ftp.mathworks.com');
dir(tmw)
mget(tmw, 'README');
type README
README
containsthefollowingtext:
Welcome to the e MathWorks s FTP site!
The MathWorks FTP P site has s a new structure:
/incoming - where you upload d files s to
/outgoing - where you pick up files from
NOTE: Files in n the e above directories will be removed after 30 days.
You may also want t to o visit the e MathWorks Web b site at
http://www.mathworks.com
10-8
PerformingFTPFileOperations
Send questions/comments/suggestions s to o ftpadmin@mathworks.com
Viewthecontentsofthe
pub
folder:
cd(tmw, 'pub')
dir(tmw)
% Close e the connection
close(tmw)
10-9
10
InternetFileAccess
DisplayHyperlinksintheCommandWindow
Inthis section...
“CreatingHyperlinkstoWebPages”onpage10-10
“TransferringFilesUsingFTP”onpage10-10
CreatingHyperlinkstoWebPages
WhencreatingahyperlinktoaWebpage,appendafullhypertextstring
onasinglelineasinputtothe
disp
or
fprintf
command. Forexample,
thefollowingcommand:
disp('<a href f = = "http://www.mathworks.com">The MathWorks s Web b Site</a>')
displaysthefollowinghyperlinkintheCommandWindow:
The MathWorks Web b Site
Whenyouclickthishyperlink,aMATLABWebbrowseropensanddisplays
therequestedpage.
TransferringFilesUsingFTP
TocreatealinktoanFTPsite,enterthesiteaddressasinputtothe
disp
commandasfollows:
disp('<a href f = = "ftp://ftp.mathworks.com">The e MathWorks s FTP Site</a>')
ThiscommanddisplaysthefollowingasalinkintheCommandWindow:
The MathWorks FTP P Site
Whenyouclickthelink,aMATLABbrowseropensanddisplaystherequested
FTPsite.
10-10
Documents you may be interested
Documents you may be interested