I'd like to export /path/to/api.trace (the result of a GPU trace, which is in some weird format) to the Wolfram cloud (so that someone else can download it and inspect on their machine). I've tried importing it as

Import[File["/path/to/api.trace"]]
Import[File["/path/to/api.trace"], "Text"]


but both fail to work. I either get

ToExpression::sntx:
Invalid syntax in or before "
Import::infer: Cannot infer format of file api.trace.".


or

\$Failed


Ultimately my goal is to feed it to

CopyFile[apiTrace, CloudObject["api.trace"]] (* Will this be downloadable? *)


How to get around this?

• Hard to say without access to the file. Does it make any difference if you omit the File part and simply use the path in Import? It should not though. How big is the file? Is is text or binary? Anyway, perhaps if the only purpose is to share with someone else, then you could use a free account on e.g. DropBox or some similar service? Nov 26, 2019 at 19:39
• @MarcoB: It doesn't make a difference. It shows as 3144639 bytes large in my console. I guess it's in binary? I'd like to use Wolfram if I can because it's so much easier to use its REPL for one-off jobs like this (making throwaway links to files for temporary sharing, etc). Nov 26, 2019 at 20:02
• MarcoB: Using "Byte" instead of "Text" seems to work in Import, but I get errors when trying to use it in CopyFile. Nov 26, 2019 at 20:03

I'm not sure what exactly you tried (particularly, what is apiTrace in your code?), but just to clarify: In the first argument of CopyFile, you want the file name, not its contents. (If you want to deploy some given content to the cloud, use CloudExport or CloudDeploy or CloudPublish.)

So it should be as simple as

CopyFile["/path/to/api.trace", CloudObject["api.trace"]]


and then the file will probably be downloaded by default if you open the cloud object URL in a browser. (It depends on the browser what exactly will happen.)

You can always copy something from the cloud back to your local file system, e.g. using

CopyFile[CloudObject["api.trace"], "/some/other/path/to/api.trace"]


If you want to give others permission to view / download the file as well, give them "Read" permission, e.g.

SetPermissions[CloudObject["api.trace"], All->"Read"]


to make it publicly available (but you could also use a particular Wolfram ID instead of All to grant permissions to a particular user).

You can also use

Import[CloudObject["api.trace"], "Byte"]


(or, equivalently, CloudImport["api.trace"], "Byte"]) to import it back into Mathematica directly from the cloud.