Skip to content
This repository has been archived by the owner on Jun 6, 2023. It is now read-only.

Sending local file with curl / ftp #41

Closed
sinsedrix opened this issue Sep 3, 2020 · 4 comments
Closed

Sending local file with curl / ftp #41

sinsedrix opened this issue Sep 3, 2020 · 4 comments

Comments

@sinsedrix
Copy link

I tried upload a local file to my ftp server using this command:

docker run --rm curlimages/curl --T test.txt ftp://ftp_user:[email protected]

I get the following error:

curl: Can't open 'test.txt'!

Of course, if I just write the command with curl, it's ok:

curl --T test.txt ftp://ftp_user:[email protected]

I suppose it can't work because test.txt is not in the container.
With other containers, I'm used to specify a -v "$PWD:/workdirectory" option, but I dont' know if it's available in this container.

Am I missing an option or a work directory to use local files?

Thanks.

@xquery
Copy link
Member

xquery commented Sep 3, 2020

yes we could make that a bit more explicit in the documentation for uploading scenarios eg. you would need to mount volume in container as you suggested (or perhaps docker copy file into container).

Something like the following works

docker run --rm -it -v "$PWD:/workdirectory" curlimages/curl -d@/workdirectory/test.txt http://httpbin.org/post

@sinsedrix
Copy link
Author

sinsedrix commented Sep 3, 2020

yes we could make that a bit more explicit in the documentation for uploading scenarios eg. you would need to mount volume in container as you suggested (or perhaps docker copy file into container).

Something like the following works

docker run --rm -it -v "$PWD:/workdirectory" curlimages/curl -d@/workdirectory/test.txt http://httpbin.org/post

It doesn't seem to work:

Warning: The file name argument
Warning: '-d@/work/test.tx
Warning: t' looks like a flag.
curl: Can't open '-d@/work/test.txt'!

Are you sure, it's not up to the image to provide/include the working directory?

Oh, it works without the -d@ prefix !

@xquery
Copy link
Member

xquery commented Sep 3, 2020

the example I provided works ... your error listing is confusing eg. refers to "/work/test.tx" and "/work/test.txt" ... closing this as I believe the question was answered (and no obvious issues) - if you think that is not the case continue to comment on this issue and i will re-open.

@xquery xquery closed this as completed Sep 3, 2020
@sinsedrix
Copy link
Author

sinsedrix commented Sep 3, 2020

the example I provided works ... your error listing is confusing eg. refers to "/work/test.tx" and "/work/test.txt" ... closing this as I believe the question was answered (and no obvious issues) - if you think that is not the case continue to comment on this issue and i will re-open.

The warning was on two lines because my real filename is long.
I manage to have it work without the -d@ prefix, as it's interpreted as an option.
Ok to close the issue.

Thanks

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants