[2021] Download Binary With Curl

0 views
Skip to first unread message

Fonda Boulay

unread,
Jan 25, 2024, 8:58:28 AM1/25/24
to nimufffilryu

But instead I use the parameter o filepath, I use the binary object inside body request, for example, some 010101101011010101010 binary code inside request instead of "/folder/filename.extension" . Because I am building a system client-server that a user can upload a file, sending by Post request to server, and the server must to take this file via $_ENV[] and insert it into a request to upload to Dropbox. And doesnt a way to server save temporary file inside your filesystem because the your provider is ephemeral, and so, because it i have to insert the file binary data inside request.

For example, using curl on the command line, this would upload a file to the remote path "/test_605632.txt" in Dropbox, telling curl to send the contents of the local file at the local (relative) path "test/test.txt" (the "@" is a way of telling curl to read from the local filesystem):

download binary with curl


Download Ziphttps://t.co/3HiJc1j4E4



@karanag In your code, you're sending the data in your 'content' variable, which just contains the string '"@" + imagePath', not the actual file data at that path. In the examples in the Dropbox API documentation, the "@" is a way of telling curl on the command line to read from the local filesystem at that path. That wouldn't necessarily work in other environments, such as using XMLHttpRequest like you are here. You'll need to update your code to pass in the actual file data. Please refer to the documentation for your platform for information on accessing file data.

it depends on the target endpoint on how it is expecting the binary file provided. Maybe it is expecting in the request body in form of base64 coded string. Just inverstigate the endpoint docu / api reference

I was hoping that someone could help me with an issue I'm having. I'm trying to replicate in Alteryx an API call that uses Curl. The host I'm making the call to requires that an XML file be attached using the '--data-binary' flag.

have you tried just using the RunCommand tool? it could also be the curl version that is delivered with Alteryx not supporting your request. If you can execute your desired command via the command line, you can use the run command tool and do exactly the same thing within Alteryx.

Thank you for the reply. I had considered that but I am on a new laptop and don't have curl installed yet. Or, at least, I thought I didn't. I completely missed where it's included with the Alteryx Designer install. I'll give it a try.

I use curl to test out my HTTP libraries all the time. Recently, I ran into an issue where when uploading a file (25mb) from curl in the command line to my common lisp app server, only about half the data showed up (12.5mb). I was doing this:

Naturally, I assumed the issue was with my libraries. It could be the cl-async library dropping packets, it could be the HTTP parser having issues, and it could be the app server itself. I mean, it has to be one of those. Curl has been around for ages, and there's no way it would just drop data. So I spent days tearing my hair out.

Finally, I ran curl with the --trace and looked at the data. It provides a hex dump of everything it sends. It's not formatted perfectly, but with vim's block select and a few handy macros, I was able to get the length of the data being sent: 12.5mb. That's right, curl was defying me. There was no error in my code at all.

I did a search online for curl not sending the full file data when using --data-binary. Nothing. So I looked over my options and found -T which looks surprisingly similar to --data-binary with the @ modifier. I tried:

When I try to use this from command line (after logging in and getting cookies, and upload_id, etc), file upload progress doesn't start. I have tried to add options to the curl command "-T 1.zip" or "--data-binary @1.zip" or making filename like "

dpkg -l grep curl
ii curl 7.64.0-4+deb10u2 armhf command line tool for transferring data with URL syntax ii libcurl3-gnutls:armhf 7.64.0-4+deb10u2 armhf easy-to-use client-side URL transfer library (GnuTLS flavour) ii libcurl4:armhf 7.64.0-4+deb10u2 armhf easy-to-use client-side URL transfer library (OpenSSL flavour) ii php7.3-curl

But when curl uploading large file it trying to fully cache it in RAM wich produces high memory load. I've tried to use -N flag from man curl which should disable buffering. But nothing happened. So my question is, is there any way to force curl write directly to socket, or could you advice me another util which will cover my needs of simple HTTP POST/PUT requests.

I use SoapUI-5.3.0. My curl request with only a binary file as attachment works fine (see below curl output). It also works fine in Postman (Google Chrome plugin). But it doesn't work in SOAP UI and throws the error "400 Bad Request: cannot parse incoming googlebuf".

The tricky extra part is the requirement for a specific Accept header in order to receive the binary asset; without the header you only receive a JSON description of the asset details. @ksluder I can confirm that when passing the necessary Accept: application/octet-stream header in the curl request that it works (with /.netrc) so everything seems fine on the GitHub front (according to their design at least).

@sstadelman I'm not familiar with requirements for GitHub Enterprise; were you adding support for pulling binary assets from the GitHub releases feature? And did it follow the API guidelines set out in the repos docs for "Get a release asset"? I'm just lost on how to indicate to SPM to include the Accept: application/octet-stream header (or if there is a way around this).

If there is no current way around this, would the Swift team consider adding something like a customHeaders: [String: String] = [:] parameter to the Target.binaryTarget method? Or is there a better way to resolve this?

It looks like Xcode 13 fails to add Swift packages that specify a binaryTarget with the URL of a GitHub asset in a private repo (even with a correctly formatted /.netrc file with suitable credentials):

@NeoNacho yes indeed, as that header would be required. However that's insufficient as it seems like HTTPClient.Request only accepts 200 as a valid response code and the GitHub REST API initially responds with a 302 when we ask it for a release asset (see my sample curl call above).

@tomerd This is happening on Xcode 13. The issue is that it fails to add Swift packages that specify a binaryTarget with the URL of a GitHub asset in a private repo (even with a correctly formatted /.netrc file with suitable credentials). I suspect this could be because

By default, the rclone binary inside a Docker container runs with UID=0 (root).As a result, all files created in a run will have UID=0. If your config and data filesreside on the host with a non-root UID:GID, you need to pass these on the containerstart command line.

This will check out the rclone source in subfolder rclone, which you can latermodify and send pull requests with. Then it will build the rclone executablein the same folder. As an initial check you can now run ./rclone version(.\rclone version on Windows).

This assumes you have a GCC compatible C compiler (GCC or Clang) in your PATH,as it uses cgo. But on Windows, thecgofuse library that the cmountimplementation is based on, also supports buildingwithout cgo, i.e. by settingenvironment variable CGO_ENABLED to value 0 (static linking). This is how theofficial Windows release of rclone is being built, starting with version 1.59.It is still possible to build with cgo on Windows as well, by using the MinGWport of GCC, e.g. by installing it in a MSYS2distribution (make sure you install it in the classic mingw64 subsystem, theucrt64 version is not compatible).

Additionally, to build with mount on Windows, you must install the third partyutility WinFsp, with the "Developer" feature selected.If building with cgo, you must also set environment variable CPATH pointing tothe fuse include directory within the WinFsp installation(normally C:\Program Files (x86)\WinFsp\inc\fuse).

You may add arguments -ldflags -s to omit symbol table and debug information,making the executable file smaller, and -trimpath to remove references tolocal file system paths. The official rclone releases are built with both of these.

On Windows, the official executables also have the version information,as well as a file icon, embedded as binary resources. To get that with yourown build you need to run the following command before the build command.It generates a Windows resource system object file, with extension .syso, e.g.resource_windows_amd64.syso, that will be automatically picked up byfuture build commands.

Instead of executing the go build command directly, you can run it via theMakefile. The default target changes the version suffix from "-DEV" to "-beta"followed by additional commit details, embeds version information binary resourceson Windows, and copies the resulting rclone executable into your GOPATH bin folder($(go env GOPATH)/bin, which corresponds to /go/bin/rclone by default).

NOTE: Remember that when rclone runs as the SYSTEM user, the user profilethat it sees will not be yours. This means that if you normally run rclone withconfiguration file in the default location, to be able to use the same configurationwhen running as the system user you must explicitly tell rclone where to findit with the --config option,or else it will look in the system users profile path (C:\Windows\System32\config\systemprofile).To test your command manually from a Command Prompt, you can run it withthe PsExecutility from Microsoft's Sysinternals suite, which takes option -s toexecute commands as the SYSTEM user.

The WinFsp service infrastructuresupports incorporating services for file system implementations, such as rclone,into its own launcher service, as kind of "child services". This has the additionaladvantage that it also implements a network provider that integrates intoWindows standard methods for managing network drives. This is currently notofficially supported by Rclone, but with WinFsp version 2019.3 B2 / v1.5B2 or laterit should be possible through path rewriting as described here.

9738318194
Reply all
Reply to author
Forward
0 new messages