Start a Conversation

Unsolved

This post is more than 5 years old

2789

February 18th, 2011 12:00

Directory management

I'm able to create/delete a directory. I'd like to store a file in the directory.

Is there any sample code?

222 Posts

February 18th, 2011 13:00

Based on some of the other threads it appears that you're using one of our wrappers.  You can find unit tests for each of the wrappers that illustrate how each method is called.

It also appears that you have discovered the uploadHelper in the wrapper.  This is indeed the way to upload objects to Atmos using the wrappers.

9 Posts

February 18th, 2011 13:00

Yes I’m using the UploadHelper class. Just seems extremely odd that no exception is thrown from the following call:

oId = uploadHelper.createObjectOnPath(new ObjectPath(directory), new File(fileToStore.getFileName()), null, ml);

What I’d also like to know is this:

If the above call is working correctly, should a file object be created in the directory.

That is not happening in my installation of ATMOS – I need to know if it is a config issue, an access rights issue or if I have a misconception about the functionality of the method.

Thanks

Anthony Catalfano

Corp IS Architecture

(309) 748-5201 / CatalfanoAnthonyF@JohnDeere.com

309-854-3221

222 Posts

February 18th, 2011 14:00

To create an object from a file in the namespace (which allows you to use directories) you should use createObjectFromFileOnPath() in the uploadHelper class.

222 Posts

February 18th, 2011 15:00

Here's an example of calling createObjectFromFileOnPath (it's PHP but the concept, method, and parameters are identical to Java) that works by the way:

$esu = new EsuRestApi( $host, $port, $uid, $secret );

$path = new ObjectPath("/test_path/filename.data");

$upload = new uploadHelper($esu);

$file = "/home/user/filename.dat";

$oid = $upload->createObjectFromFileOnPath($path, $file);

9 Posts

February 19th, 2011 06:00

I’m over my allotted time for working on ATMOS.

Anthony Catalfano

Corp IS Architecture

(309) 748-5201 / CatalfanoAnthonyF@JohnDeere.com

309-854-3221

9 Posts

February 19th, 2011 06:00

What version of the java api are you referring to?

I’ve downloaded the latest which is

EsuJava_1.4.0.29.zip

There is no method called createObjectFromFileOnPath in the UploadHelper class.

Anthony Catalfano

Corp IS Architecture

(309) 748-5201 / CatalfanoAnthonyF@JohnDeere.com

309-854-3221

5 Practitioner

 • 

274.2K Posts

February 22nd, 2011 15:00

Hi Anthony,

Building on your example

directory = "/dir1/";

File = "file.txt";

oid = uploadHelper.createObjectOnPath(new ObjectPath(directory), new File(fileToStore.getFileName()), null, ml);

   If the ObjectPath has a slash at the end of it then the payload is ignored and the request is a POST to just create the directory.  If the ObjectPath is a file name like so ObjectPath("/dir1/file.txt") then file.txt will get created along with the directory dir1.

Hope this helps

thanks

-Dan

9 Posts

February 22nd, 2011 17:00

Thank you. That works. Not what I would call intuitive but hey – this stuff is new …

Anthony Catalfano

Corp IS Architecture

(309) 748-5201 / CatalfanoAnthonyF@JohnDeere.com

309-854-3221

222 Posts

February 22nd, 2011 17:00

Ahh --- I stand corrected.  createObjectFromFileOnPath() exists in the other wrappers.

I agree with you about the not-so-intuitive nature of the ObjectPath object.  I made the same mistake too, but it sorta makes sense as to why.

Just to add to what Dan said:

When you call createObjectOnPath() (intending to create a file object) the wrapper is sending this:  POST /rest/namespace/dir/path/file.txt

When you call createObjectOnPath() (intending to create a directory) the wrapper is sending this:  POST /rest/namespace/dir/

So the trailing slash is important.

No Events found!

Top