src/Services/BaseService.php
protected function getServiceAttachment($path = null)
    {
        $attachment = [];
        $file = $path;
        if ($this->request instanceof ServiceRequestInterface) {
            $file = $this->request->input('import_url', $this->request->input('attachment', $path));
        }

        if (!empty($file) && is_array($file)) {
            if (isset($file['service'])) {
                $files = [$file];
            } else {
                $files = $file;
            }

            try {
                foreach ($files as $f) {
                    if (is_array($f)) {
                        $service = array_get($f, 'service');
                        $path = array_get($f, 'path', array_get($f, 'file_path'));
                        Session::replaceLookups($service);
                        Session::replaceLookups($path);

                        if (empty($service) || empty($path)) {
                            throw new BadRequestException('No service name and file path provided in request.');
                        }

                        if (Session::checkServicePermission(Verbs::GET, $service, $path, Session::getRequestor(),
                            false)) {
                            /** @var \DreamFactory\Core\Contracts\ServiceResponseInterface $result */
                            $result = ServiceManager::handleRequest(
                                $service,
                                Verbs::GET,
                                $path,
                                ['include_properties' => true, 'content' => true, 'is_base64' => true]
                            );

                            if ($result->getStatusCode() !== 200) {
                                throw new InternalServerErrorException(
                                    'Could to retrieve attachment file: ' .
                                    $path .
                                    ' from storage service: ' .
                                    $service);
                            }

                            $content = $result->getContent();
                            $content = base64_decode(array_get($content, 'content', ''));
                            $fileName = basename($path);
                            $filePath = sys_get_temp_dir() . '/' . $fileName;
                            file_put_contents($filePath, $content);
                            $attachment[] = new Attachment($filePath, $fileName);
                        } else {
                            throw new ForbiddenException(
                                'You do not have enough privileges to access file: ' .
                                $path .
                                ' in service ' .
                                $service);
                        }
                    }
                }
            } catch (\Exception $e) {
                throw new InternalServerErrorException('Failed to get attachment file from storage service. ' .
                    $e->getMessage());
            }
        }

        return $attachment;
    }
protected function getServiceAttachment($path = null)
    {
        $attachment = [];
        $file = $path;
        if ($this->request instanceof ServiceRequestInterface) {
            $file = $this->request->input('import_url', $this->request->input('attachment', $path));
        }

        if (!empty($file) && is_array($file)) {
            if (isset($file['service'])) {
                $files = [$file];
            } else {
                $files = $file;
            }

            try {
                foreach ($files as $f) {
                    if (is_array($f)) {
                        $service = array_get($f, 'service');
                        $path = array_get($f, 'path', array_get($f, 'file_path'));
                        Session::replaceLookups($service);
                        Session::replaceLookups($path);

                        if (empty($service) || empty($path)) {
                            throw new BadRequestException('No service name and file path provided in request.');
                        }

                        if (Session::checkServicePermission(Verbs::GET, $service, $path, Session::getRequestor(),
                            false)) {
                            /** @var \DreamFactory\Core\Contracts\ServiceResponseInterface $result */
                            $result = ServiceManager::handleRequest(
                                $service,
                                Verbs::GET,
                                $path,
                                ['include_properties' => true, 'content' => true, 'is_base64' => true]
                            );

                            if ($result->getStatusCode() !== 200) {
                                throw new InternalServerErrorException(
                                    'Could to retrieve attachment file: ' .
                                    $path .
                                    ' from storage service: ' .
                                    $service);
                            }

                            $content = $result->getContent();
                            $content = base64_decode(array_get($content, 'content', ''));
                            $fileName = basename($path);
                            $filePath = sys_get_temp_dir() . '/' . $fileName;
                            file_put_contents($filePath, $content);
                            $attachment[] = new Attachment($filePath, $fileName);
                        } else {
                            throw new ForbiddenException(
                                'You do not have enough privileges to access file: ' .
                                $path .
                                ' in service ' .
                                $service);
                        }
                    }
                }
            } catch (\Exception $e) {
                throw new InternalServerErrorException('Failed to get attachment file from storage service. ' .
                    $e->getMessage());
            }
        }

        return $attachment;
    }
Gets file(s) stored in storage service(s) for attachment.

@param null|string|array $path

@return array
@throws \DreamFactory\Core\Exceptions\InternalServerErrorException