Skip to content

Instantly share code, notes, and snippets.

@lucenarenato
Created October 7, 2022 21:38
Show Gist options
  • Select an option

  • Save lucenarenato/f1392f24545b885ca40b90a4365096fb to your computer and use it in GitHub Desktop.

Select an option

Save lucenarenato/f1392f24545b885ca40b90a4365096fb to your computer and use it in GitHub Desktop.
Exemplo File Upload Using Multipart Form Data

segue o exemplo de uma forma alternativa.

/**
* @OA\Post(
* tags={"Files"},
* description="Envia os arquivos especificados para o servidor.",
* path="/files/upload",
* security={{"bearerAuth":{}}},
* @OA\RequestBody(
* @OA\MediaType(
* mediaType="multipart/form-data",
* @OA\Schema(
* type="object",
* @OA\Property(
* description="file to upload",
* property="files[]",
* type="array",
* @OA\Items(
* type="string",
* format="binary",
* ),
* )
* )
* )
* ),
* @OA\Response(
* response=200,
* description="Successful operation",
* ),
* @OA\Response(
* response=401,
* description="Unauthenticated",
* ),
* @OA\Response(
* response=403,
* description="Forbidden"
* )
* )
* @param \Illuminate\Http\Request $request
* @return \Symfony\Component\HttpFoundation\BinaryFileResponse
*/
@lucenarenato

Copy link
Copy Markdown
Author
     * @OA\Post(
     *     path="/admin/resources/create",
     *     tags={"Resources"},
     *     summary="Create Resources",
     *     description="Upload the specified files to the server.",
     *     operationId="adminResourcesCreate",
     *     security={
     *        {"sanctum": {}},
     *     },
     *     @OA\RequestBody(
     *        @OA\MediaType(
     *            mediaType="multipart/form-data",
     *            @OA\Schema(
     *                type="object",
     *                @OA\Property(
     *                    property="title",
     *                    type="string",
     *                    title="Title",
     *                    description="Title",
     *                    example="Photo"
     *                ),
     *                @OA\Property(
     *                     property="description",
     *                     type="string",
     *                     title="Description",
     *                     description="Description",
     *                     example="Name file photo"
     *                ),
     *                @OA\Property(
     *                   description="file to upload",
     *                   property="file",
     *                   type="string",
     *                   format="binary",
     *                )
     *            )
     *        )
     *     ),
     * @OA\Response(
     * response=200,
     * description="Successful operation",
     * ),
     * @OA\Response(
     * response=401,
     * description="Unauthenticated",
     * ),
     * @OA\Response(
     * response=403,
     * description="Forbidden"
     * )
     * )
     * @param \Illuminate\Http\Request $request
     * @return \Symfony\Component\HttpFoundation\BinaryFileResponse
     */

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment