Skip to content

Commit 0f7d2d4

Browse files
committed
fixed #187 If no attachment save directory exists, it will be recursively created.
1 parent abcbbb7 commit 0f7d2d4

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/Attachment/AttachmentService.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@ class AttachmentService extends \JiraRestApi\JiraClient
1717
* @param $id string|int attachment Id
1818
* @outDir string downloads the content and store into outDir
1919
* @overwrite boolean determines whether to overwrite the file if it already exists.
20+
* @mode int outDir creation mode.
21+
* @recursive boolean Allows the creation of nested directories specified in the pathname.
2022
*
2123
* @throws \JiraRestApi\JiraException
2224
* @throws \JsonMapper_Exception
2325
*
2426
* @return \JiraRestApi\Issue\Attachment
2527
*/
26-
public function get($id, $outDir = null, $overwrite = false)
28+
public function get($id, $outDir = null, $overwrite = false, $mode = 0777, $recursive = true)
2729
{
2830
$ret = $this->exec($this->uri.$id, null);
2931

@@ -39,7 +41,7 @@ public function get($id, $outDir = null, $overwrite = false)
3941

4042
// download contents
4143
if (!file_exists($outDir)) {
42-
mkdir($outDir);
44+
mkdir($outDir, $mode, $recursive);
4345
}
4446

4547
// extract filename
@@ -50,6 +52,8 @@ public function get($id, $outDir = null, $overwrite = false)
5052
}
5153

5254
$this->download($attachment->content, $outDir, $file);
55+
56+
return $attachment;
5357
}
5458

5559
/**

0 commit comments

Comments
 (0)