How to use Ant Design Upload component it's not sending anything - antd

I'm trying to use the Upload component
<Upload
action="//localhost:3001/api/v1/file/upload"
listType="picture-card"
fileList={fileList}
onPreview={this.handlePreview}
onChange={this.handleChange}
>
but on the endpoint API I receive nothing when I select the file to upload.

Would you try this? I think both '//' will not evaluate to your localhost endpoint, try either ommiting that or doing 'http://' or 'https://'
<Upload
action="localhost:3001/api/v1/file/upload"
listType="picture-card"
fileList={fileList}
onPreview={this.handlePreview}
onChange={this.handleChange}
>

Related

Is it possible to compose URL that forces browser to download file instead of play it?

Let say we have some file at http://somedomain.com/somedir/file.mp4.
When I send such URL to someone, I would like that browser start download, not play automatically.
Is it possible to compose URL in such manner to give browser instruction to start download instead of play it? With some parameter included maybe?
You can't do that by just sending the URL to someone.
What you can do is create a simple file which forces the user to download the file by setting the mime type of the response to octet/stream, which is the way of telling the browser the file can not embedded.
Below is an example in PHP taken from this website.
<?php
$file = $_GET['file'];
header ("Content-type: octet/stream");
header ("Content-disposition: attachment; filename=".$file.";");
header("Content-Length: ".filesize($file));
readfile($file);
exit;
?>

How to upload a file in Telegram Bott api using Http client?

I have tried to send files using multipart form data, but all I get is the following error:
{"description":"Error: Bad Request: chat_id is empty","error_code":400,"ok":false}
Here is my code snippet. Can anyone help me out where I am committing an error?
public HttpResponse<jsonnode> sendDocument(Integer chat_id,File f1) throws UnirestException {
return Unirest.post(endpoint + token + "/sendDocument")
header("accept", "application/json")
.field("chat_id", chat_id)
.field("document", f1)
.asJson();
}
well, it said chat_id is empty. that's an obvious error!
but for your question, there is only two ways to sendDocument to telegram.
that file is already is in their servers, so you should just pass the file_id in "document" field
you want to upload a file from your device and as they said
Must be posted using multipart/form-data in the usual way that files are uploaded via the browser
if you are doing the upload section correct, then just make sure chat_id is not empty.

Delphi 7 TidHttp.post not sending data to server

I am using this to post a form:
c := tidhttp.Create(self);
p := tstringlist.Create;
p.Add('field=value');
s := c.Post('http://www.test.com/action.php', p);
p.Free;
c.Free;
Tried hosting online and tried Xampp, I get the same results, no data received.
The form:
<form action="action.php" method="POST" name="test">
<input type="text" name="field"><br>
<input type="submit">
</form>
There are so many answers suggesting that I am doing it right but the data is not received
Tried TStringSTream.create(UTF8String('field=value')) but nothing
Your HTML webform is configured to submit its data to http://www.test.com/action.php (assuming the HTML page resides at http://www.test.com/).
Your Indy code is Post()ing its data to http://www.test.com instead. You need to use the correct URL when posting data in code:
s := c.Post('http://www.test.com/action.php', p);
If I had to guess (and you should never make people guess), when you are Post()'ing to http://www.test.com, you are likely getting redirected to http://www.test.com/ (notice the trailing slash). If the redirect uses reply code 303, or uses 302 and you have the hoTreat302Like303 option enabled in the TIdHTTP.HTTPOptions property, then TIdHTTP wwill send a GET instead of a POST to the new URL being redirected to.

Amazon S3 : Access Denied for URL using symbols

I would like to download some files uploaded on my S3 Server.
For the moment, all my buckets and files inside them are public, so I can download what I want.
Unfortunately, I can't access to files using special characters like a space or "&"...
I tried to change the special characters in my URL by HTML code :
http://s3-eu-west-1.amazonaws.com/custom.bucket/mods/b&b.jar
by
http://s3-eu-west-1.amazonaws.com/custom.bucket/mods/b%26b.jar
But I always have the same error :
<Error>
<Code>AccessDenied</Code>
<Message>Access Denied</Message>
<RequestId>3E987FCE07075166</RequestId>
<HostId>
O2EIujdbiAeYg44rsezQlargfT7qVSL8SpqbTxkd/1UwxQrwZ3SJ+R3NlHyGF7rI
</HostId>
</Error>
Anybody could resolve this problem ?
I can't rename them because there are used by other applications.
I am able to download public files with '&' in the name with no problems using curl:
curl https://s3.amazonaws.com/mybucket/test/b%26b.jar
Recheck the permissions on your file using the AWS console. Make sure the file has "Grantee: Everyone", and Open/Download permissions clicked, as in this screenshot:
Make sure to click the "save" button after you add these credentials. Alternatively, try using your security credentials.
I am able to download file with special character:
# wget --no-check-certificate https://s3-us-west-2.amazonaws.com/bucket1234/b%26b.jar
--2013-12-01 14:15:20-- https://s3-us-west-2.amazonaws.com/bucket1234/b%26b.jar
Resolving s3-us-west-2.amazonaws.com... 54.240.252.26
Connecting to s3-us-west-2.amazonaws.com|54.240.252.26|:443... connected.
WARNING: certificate common name `*.s3-us-west-2.amazonaws.com' doesn't match requested host name `s3-us-west-2.amazonaws.com'.
HTTP request sent, awaiting response... 200 OK
Length: 0 [application/x-java-archive]
Saving to: `b&b.jar'
[ <=> ] 0 --.-K/s in 0s
2013-12-01 14:15:22 (0.00 B/s) - `b&b.jar' saved [0/0]
Are you sure that this file is "Publicly visible"? could you double check the permissions for this file ? This is definitely not an issue with the special character.
Can you just login to aws s3 console and check what download link shows there?
Is there any mismatch in the link because of double encoding? Please make sure you are not doing any URL encoding from your code while uploading file.
In your case it could be:
http://s3-eu-west-1.amazonaws.com/custom.bucket/mods/b%2526b.jar

How to know the url that is calling the destination url using curl in the destination url?

Okay, I have this setup:
//in example1.com, I am setting cURL <br />
$c = curl_init(); <br />
curl_setopt($c, CURLOPT_URL, 'http://example2.com');
//now in example2.com <br />
Is it possible to get the URL "example1.com" which is calling this URL (example2.com)?
Using file_get_contents('php://input'), I can get the input of example1.com but how can I get the URL which is the "example1.com" here in example2.com?
Not sure exactly what you're asking. If you want to know the URL you script is invoked as that is just a matter of something like
"http://" . $_SERVER["SERVER_NAME] . $_SERVER["REQUEST_URI"]
But if you are asking to know the URL of the client which requested you that is not possible. Because there is nothing to guarantee you were invoked by another URL. It could just be a user typing someting into a browser, a web crawler, a cron job, etc...
The only thing you can discover for sure about your client is the IP address and port
$_SERVER["REMOTE_ADDR"]
$_SERVER["REMOTE_PORT"]
If you client is a friently HTTP client you can get some other info such as
$_SERVER["HTTP_USER_AGENT"]
Now I'm not sure thats what you were asking, but its what I took from it.

Resources