Start a Conversation

Unsolved

This post is more than 5 years old

5514

January 13th, 2013 19:00

How to rename object?

Dear all,

I try to use the following code to rename my object.

EsuRestApi api = new EsuRestApi(HOST, 443, TOKENID, SECRETKEY);

api.rename(new ObjectPath(old_filename),

                 new ObjectPath(new_filename), false);

However i got some problems when i was testing.

Am I using wrong method to rename object?

01-14 11:31:47.655: E/AndroidRuntime(29647): FATAL EXCEPTION: main

01-14 11:31:47.655: E/AndroidRuntime(29647): com.emc.esu.api.EsuException: There was a mismatch between the signature in the request and the signature computed by the server.

01-14 11:31:47.655: E/AndroidRuntime(29647):           at com.emc.esu.api.rest.EsuRestApi.handleError(EsuRestApi.java:2325)

01-14 11:31:47.655: E/AndroidRuntime(29647):           at com.emc.esu.api.rest.EsuRestApi.rename(EsuRestApi.java:2033)

01-14 11:31:47.655: E/AndroidRuntime(29647):           at com.cx.ecs.MainActivity$6.onClick(MainActivity.java:429)

01-14 11:31:47.655: E/AndroidRuntime(29647):           at android.view.View.performClick(View.java:4084)

01-14 11:31:47.655: E/AndroidRuntime(29647):           at android.view.View$PerformClick.run(View.java:16966)

01-14 11:31:47.655: E/AndroidRuntime(29647):           at android.os.Handler.handleCallback(Handler.java:615)

01-14 11:31:47.655: E/AndroidRuntime(29647):           at android.os.Handler.dispatchMessage(Handler.java:92)

01-14 11:31:47.655: E/AndroidRuntime(29647):           at android.os.Looper.loop(Looper.java:137)

01-14 11:31:47.655: E/AndroidRuntime(29647):           at android.app.ActivityThread.main(ActivityThread.java:4745)

01-14 11:31:47.655: E/AndroidRuntime(29647):           at java.lang.reflect.Method.invokeNative(Native Method)

01-14 11:31:47.655: E/AndroidRuntime(29647):           at java.lang.reflect.Method.invoke(Method.java:511)

01-14 11:31:47.655: E/AndroidRuntime(29647):           at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)

01-14 11:31:47.655: E/AndroidRuntime(29647):           at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)

01-14 11:31:47.655: E/AndroidRuntime(29647):           at dalvik.system.NativeStart.main(Native Method)

281 Posts

January 14th, 2013 08:00

What is the destination filename?

Since the destination file path is sent as an HTTP header, it's important that the EsuRestApi object is in Unicode mode.  This is supported by Atmos 1.4.2+ and 2.0.1+.  You can enable it with:

api.setUnicodeEnabled(true);

110 Posts

January 14th, 2013 09:00

Make sure your secret key is correct.  You must include the trailing equals sign as well.

13 Posts

January 14th, 2013 09:00

Hi Jason,

Sorry I am new programer in developing atmos so I don't know what is destination filename.

I have try to enable unicode however it also not work.

The following is my code of upload file and rename file.

try {           

     EsuApi atmosApi = new EsuRestApi( HOST, 443, TOKENID, SECRETKEY );

     UploadHelper uploadHelper = new UploadHelper(atmosApi);

     uploadHelper.createObjectOnPath(new ObjectPath ("/test/text2.txt"), new File(DIR+"/text2.txt"), null, null);

     atmosApi.setUnicodeEnabled(true);

     atmosApi.rename(new ObjectPath("/test/text2.txt"), new ObjectPath("/test/hello.txt"), true);

} catch(EsuException ex){

     System.out.println(ex.getMessage());

}

281 Posts

January 14th, 2013 09:00

This all looks fine to me.  What version of the Java API are you using?  What version of Atmos? You can call getServiceInformation to get the version.

Are you using a service provider (e.g. AT&T)?

13 Posts

January 14th, 2013 18:00

Hi jason,

My atmos version is 2.0.1.

Yes, I am using service provider to access atmos.

13 Posts

January 14th, 2013 18:00

Hi chris,

YA...I use same correct secret key. I also include the trailing equals sign as well.

110 Posts

January 14th, 2013 20:00

Are you still getting the same error message (mismatch between the signature)?  That means either the secret key is bad or something's wrong with the headers.  Since you're using our SDK, I'm inclined to believe it's the prior.  Are you absolutely SURE your secret key is correct?  Is it something you're typing in on the emulator or a string in the code?

The code you show here does not have any non-latin characters, so unless I'm missing something, I don't think that's the problem.  However, when enabling UTF-8 encoding, be sure to do that right away, (i.e. before calling createObject).

If you're using the correct token ID and secret key and still getting this message, I would start debugging by hard-coding the tokenID and secret key inside your app first and use ASCII characters in the file names.  If that still doesn't work, perhaps there is a problem in the encryption library when used with Android.  Note that we have not tested the SDK on that platform (it's unfortunate we would even have to since it's Java).

If it does work, then the problem is in the handling of the credentials.

13 Posts

January 14th, 2013 20:00

Am I need to set permission?

13 Posts

January 15th, 2013 03:00

HI Chris,

I have try you suggestion but I still getting the same error.

I have double check my token ID and secret key. It is correct.Also I have try to hard code to my program.

Am I missing some setting of EsuApi ?

Is there any other method I can use to change the object name?

Thanks you.

281 Posts

January 15th, 2013 07:00

Are you behind a firewall or proxy?  We've seen some instances where corporate firewalls either modify certain HTTP headers and/or add/remove headers that somehow affects the signature of the request (e.g. change "Content-Type").  Are you running your own internal Atmos or are you using a service provider like AT&T?

13 Posts

January 15th, 2013 10:00

Hi jason,

I am developing atmos on android.

Is that need to set headers?

Yes, I am running my own internal Atmos.


281 Posts

January 15th, 2013 10:00

No, the SDK should set all of the headers for you.  The problem is that some firewalls and proxies will change the headers, breaking the signature.  I'll send you a private message with my email so we can debug this offline.

2 Posts

October 11th, 2013 04:00

How to set proxy for EsuRestApi

for example :

In atmosapi, we have set proxy setting as follows

AtmosConfig config = new AtmosConfig(userId, secretKey,

                        new URI(ENDPOINT));

                URI proxyUri = new URI(proxyUrl);

                config.setProxyUri(proxyUri);

                atmos = new AtmosApiClient(config);

Could you please guide, how to set proxy setting as above, in EsuRestApi?

110 Posts

October 11th, 2013 08:00

You should be able to specify a proxy for EsuRestApi by setting the standard "http.proxyHost" and "http.proxyPort" system properties of the JVM, but be aware that this will affect all connections, not just connections to Atmos.

As part of the command line:

-Dhttp.proxyHost=hostname -Dhttp.proxyPort=8888

In code:

System.setProperty("http.proxyHost", proxyHost);

System.setProperty("http.proxyPort", proxyPort);

Also, EsuRestApiApache supports proxies directly.  This does add a dependency on the httpclient libraries (included in the distribution package).

EsuApi esu = new EsuRestApiApache(host, port, uid, sharedSecret);

((EsuRestApiApache) esu).setProxy(proxyHost, proxyPort);

// specify user/password as 3rd and 4th parameters

2 Posts

October 14th, 2013 22:00

Thanks a lot Chris..

No Events found!

Top