Skip to content

Commit ab83268

Browse files
committed
create media api resource
1 parent fe1a0fc commit ab83268

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

CmsSync/Model/Objectmodel/Api.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,5 +121,29 @@ public function updateBlock($data)
121121

122122
}
123123

124+
/**
125+
* @param $data
126+
*/
127+
public function createMedia($data)
128+
{
129+
$fileName = $data['fileName'];
130+
$file = base64_decode($data['file']);
131+
$filePath = Mage::getBaseDir('media') . DS . $fileName;
132+
133+
if(! file_exists($filePath)){
134+
135+
try{
136+
137+
file_put_contents($filePath, $file);
138+
}catch (Exception $e){
139+
Mage::logException($e);
140+
}
141+
142+
}
143+
144+
Mage::log($fileName);
145+
}
146+
147+
124148

125149
}

CmsSync/etc/api.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@
3232
<title>Update Block</title>
3333
<method>updateBlock</method>
3434
</block_update>
35+
<block_media translate="title" module="calindiacon_cmssync">
36+
<title>Update Media file</title>
37+
<method>createMedia</method>
38+
</block_media>
3539
<info translate="title" module="calindiacon_cmssync">
3640
<title>Retrieve cutomers data with addresses</title>
3741
<method>info</method>

0 commit comments

Comments
 (0)