Method sendFile

@access public

@param  FormData $body

@return Response
766890
public function sendFormData( FormData$body ):Response
	{
		if(!( in_array( $this->method, [ 'POST', 'PUT', 'PATCH', ] ) )){
			throw new \Exception('FormData must be send with method POST, PUT or PATCH');
		}

		$body->setRequest( $this );

		return $this->send("$body");
	}
1066288
protected function getUpdateEvent($formData)
    {
        $event = new HookUpdateEvent($formData['id']);

        return $this->hydrateEvent($event, $formData, true);
    }
1354750
public function check_data($formdata) {
        $field = $this->_name;

        if (array_key_exists($field, $formdata) and $formdata->$field !== '') {
            return array('value' => (string)$formdata->$field);
        }

        return false;
    }
1085812
public function setSubscriptionUsageData(SetUsageData\RequestData $requestData)
    {
        $request = new SetUsageData\Request($requestData);

        return $this->sendRequest($request, SetUsageData\ApiResponse::class);
    }
1298690
public function sendData($data)
    {
        $httpResponse = $this->httpClient->post($data['url'], null, $data['params'])->send();

        // The body is a string.
        $body = $httpResponse->getBody();

        // Split into lines.
        $data = json_decode($body);

        return $this->response = new OAuthConfirmResponse($this, $data);
    }
498037
public function preSetData(FormEvent $event)
    {
        $entity = $event->getData();
    
        if ($entity instanceof FileInterface && null !== $entity->getId()){
            try {
                $this->fileManager->copyFileToTemporaryDirectory($entity);
            } catch (\Gaufrette\Exception\FileNotFound $e) {
                $event->setData(null);
            }
        }
    }
886165
protected function send(
        ResponseInterface $response,
        string $body): ResponseInterface
    {
        if (!$body) {
            $response = $this->sendErrorDocument($response);
        }
        unset($this->errorDocument);
        $response = $response->withHeader(
            Response::HEADER_CONTENT_LENGTH,
            (string) strlen($body));
        header(Response::PROTOCOL
             . $response->getProtocolVersion() . " "
             . $response->getStatusCode() . " "
             . $response->getReasonPhrase());
        foreach ($response->getHeaders() as $key => $value) {
            header($key . ": " . implode("; ", $value));
        }
        $response->getBody()->write($body);
        return $response;
    }
131366
public function send($endpoint, $options = [], $body = '')
    {
        return $this->client->post(
            $endpoint . '?' . http_build_query($options),
            [
                'body' => $body,
            ]
        );
    }
1341491
@POST
  @Path("/upload")
  @Consumes(MediaType.MULTIPART_FORM_DATA)
  public Response uploadFile(
      @FormDataParam("file") InputStream uploadedInputStream,
      @FormDataParam("file") FormDataContentDisposition fileDetail) {

    Config config = createConfig();

    if (uploadedInputStream == null) {
      String msg = "input stream is null";
      LOG.error(msg);
      return Response.status(Response.Status.BAD_REQUEST)
          .type(MediaType.APPLICATION_JSON)
          .entity(Utils.createMessage(msg)).build();
    }
    if (fileDetail == null) {
      String msg = "form data content disposition is null";
      LOG.error(msg);
      return Response.status(Response.Status.BAD_REQUEST)
          .type(MediaType.APPLICATION_JSON)
          .entity(Utils.createMessage(msg)).build();
    }

    String uploadDir = config.getStringValue(FILE_SYSTEM_DIRECTORY);

    final String fileName = UUID.randomUUID() + "-" + fileDetail.getFileName();

    final String uploadedFileLocation
        = uploadDir + "/" + fileName;

    // save it
    try {
      FileHelper.writeToFile(uploadedInputStream, uploadedFileLocation);
    } catch (IOException e) {
      LOG.error("error uploading file {}", fileDetail.getFileName(), e);
      return Response.serverError()
          .type(MediaType.APPLICATION_JSON)
          .entity(Utils.createMessage(e.getMessage()))
          .build();
    }

    String uri = String.format("http://%s:%s/api/v1/file/download/%s",
        getHostNameOrIP(), getPort(), fileName);

    return Response.status(Response.Status.OK).entity(uri).build();
  }
488117
public function post($resource, $body = null, $params = [])
    {
        return $this->send($this->prepare('POST', $resource, $body, $params));
    }
472139
protected function sendPost(string $uri, array $query = [], array $body = []) : array {
        return $this->sendRequest(
            'POST',
            $uri,
            $query,
            $body
        );
    }
54194
public function send()
	{
		if(!$this->verify())
			throw new \MalformesResponseException("Malformed response");
		else
		{
			http_response_code($this->statusCode);
			
			foreach($this->headers as $header => $value)
			{
				header($header . ': ' . $value);
			}
		}
		
		echo $this->body;
	}
416524
public function send()
    {
        header($this->getStatusStr());

        foreach($this->headers as $header => $value) {
            header(sprintf("%s: %s", $header, implode(',', $value)));
        }

        $body = $this->getBody();

        if ($body->isAttached()) {
            $body->rewind();
            while (!$body->eof()) {
                echo $body->read($this->bodySize);
            }
        }
    }
1164766
public function sendData($data)
    {
        $response = $this->braintree->transaction()->releaseFromEscrow($data['transactionId']);

        return $this->createResponse($response);
    }
1012497
public function send($to, $subject, $body, $headers)
    {
        return mail(
            $to,
            $subject,
            $body,
            $headers
        );
    }
535078
public function sendAsync($method, $uri, $body = null, array $query = [], array $headers = [], array $options = [])
    {
        try {
            $this->validateMethod($method);
        } catch (\InvalidArgumentException $e) {
            return rejection_for($e);
        }

        $query = array_merge($this->getDefaultQuery(), $query);
        $headers = array_merge($this->getDefaultHeaders(), $headers);

        return $this->client->sendAsync($method, $uri, $body, $query, $headers, $options)->then(
            function (ResponseInterface $response) {
                $this->lastResponse = $response;

                $this->validateResponse($this->lastResponse);

                return $this->lastResponse;
            }
        );
    }
236173
public function sendMessage($body)
    {
        $action = 'sendMessage';
        
        $telegram = [
            'chat_id' => $body['recipient']['id']
        ];

        $message = $body['message'];

        // Send Text
        if (isset($message['text'])) {
            $telegram['text'] = $message['text'];
        }

        // Sending Attachment
        if (isset($message['attachment']['type'])) {

             // Send Audio, Video, Image, File
            $convert = [
                'image' => 'photo',
                'audio' => 'audio',
                'video' => 'video',
                'file'  => 'document'
            ];

            foreach ($convert as $facebook_template => $telegram_template)
            {
                if ($message['attachment']['type'] === $facebook_template) {
                    $telegram[$telegram_template] = $message['attachment']['payload']['url'];
                    $action = 'send' . ucfirst($telegram_template);

                    return $this->callMethod($action, $telegram);
                }
            }
            
            // Sending Button, Generic, List
            if ($message['attachment']['type'] === 'template' && 
                isset($message['attachment']['payload'])):

                // Facebook Button will be converted to InlineKeyboard
                if ($message['attachment']['payload']['template_type'] === 'button') {
                    return $this->sendButtons($message['attachment']['payload']);
                }

                // Facebook Generic will be converted to Image + Text + Button
                if ($message['attachment']['payload']['template_type'] === 'generic') {
                    return $this->sendGeneric($message['attachment']['payload']);
                }
            endif;
        }

        // Facebook Quick Replies will be converted to ReplyKeyboardMarkup
        if ( ! empty($message['quick_replies'])) {
            $telegram['reply_markup'] = [
                'keyboard' => [],
                'one_time_keyboard' => true,
            ];

            foreach ($message['quick_replies'] as $reply) {
                if ($reply['content_type'] === 'text') {
                    $telegram['reply_markup']['keyboard'][] = [
                        [
                            'text'  => $reply['title']
                        ]
                    ];
                }

                if ($reply['content_type'] === 'location') {
                    $telegram['reply_markup']['keyboard'][] = [
                        [
                            'text'              => 'Send Location',
                            'request_location'  => true
                        ]
                    ];
                }
            }
        }

        // We have to json encode the reply_markup
        if (isset($telegram['reply_markup'])) {
            $telegram['reply_markup'] = json_encode($telegram['reply_markup']);
        }

        // Facebook Quick Replies will convert to InlineKeyboard
        return giga_remote_post($this->getResource($action), $telegram);
    }