H
H
HellWalk2020-08-24 15:18:44
linux
HellWalk, 2020-08-24 15:18:44

What does the @ symbol mean in a file path?

I encountered a strange error when working with an external API - if the path to the file is without the @ symbol, then everything works fine:

curl -k --location --request POST 'https://api.example/file-load/' --header 'Content-Type: multipart/form-data' --form 'filedata=/var/www/file.jpg'

{"message":"Файл с успешно загружен"}


If you add @:

curl -k --location --request POST 'https://api.example/file-load/' --header 'Content-Type: multipart/form-data' --form '[email protected]/var/www/file.jpg'

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>413 Request Entity Too Large</title>
</head><body>
<h1>Request Entity Too Large</h1>
The requested resource<br />/file-load/<br />
does not allow request data with POST requests, or the amount of data provided in
the request exceeds the capacity limit.
</body></html>


What is the @ symbol in a file path?

And it is exactly what is required in the specification for curl in PHP:

All data sent in an HTTP POST request. To transfer a file, precede the file name with @ and also use the full path to the file.

https://www.php.net/manual/ru/function.curl-setopt.php

UPDATE
@ is a required parameter to specify the path to the file
https://curl.haxx.se/docs/manpage.html#-F

For checks, I took an example of receiving a file in PHP, tried to send the file with curl, without @ - I got an error.
Why does the required API have the opposite, with @ error and without it, ok - we will deal with them already.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
Lynn "Coffee Man", 2020-08-24
@HellWalk

man-curl

[...] To force the 'content' part to be a file, prefix the file name with an @ sign.

S
Sanes, 2020-08-24
@Sanes

413 Request Entity Too Large
This is the Nginx answer

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question