Start a Conversation

Unsolved

This post is more than 5 years old

11128

June 16th, 2011 02:00

Atmos- RESTfUL API -C#.NET

Hi all,

     I  am new to atmos and trying to access it using REST API.

     Trying to create a .net application using the predefined  wrapper bindings to access atmos.

     Is there any document to start up things on how to create a client application using REST API?

     Please help! Thanks in advance.

222 Posts

June 16th, 2011 07:00

There is indeed a quick start guide for .NET located here:

https://community.emc.com/docs/DOC-10404

Raj

16 Posts

June 17th, 2011 02:00

Hey bala,

          Thanks for the reply. Actually we have a file system and need to copy the files from there  to Atmos.

        

          Atmos exposes REST API so we trying to create a tool which does the migration.

          Link which you have shared creates new object in the Atmos. But is there any other guide or document which helps to connect Atmos and do the copy operation.

          Also the tool should be a web application or it can also be a windows application??

         Please reply.  Thanks in adance.

222 Posts

June 17th, 2011 08:00

The example does indeed only depict interacting with Atmos.  Unfortunately, we don't have examples of all the possible ways in which data can be sourced to write to Atmos.

The Atmos REST API can be accessed from any number of platforms whether web, desktop client, mobile, etc irrespective of operating system.  Our .NET wrapper will be limited to .NET compatible apps and development environments.

16 Posts

June 19th, 2011 23:00

Actually i have downloaded the .net wrapper bindings but i could not find any inbuild method to copy files. So i am assuming that after making the connection to ATmos do i have to use the microsoft .net System.IO.File.Copy( fileToCopy, newLocation ); to do the copy operation? is it the way to do this? Please help!!!

Thanks in advance!!!

222 Posts

June 20th, 2011 06:00

That' won't work because the destination of the file copy operation is a file system.

If you're using the UploadHelper class in the .NET Atmos wrapper you should read the file into a byte array and use that variable in either the CreateObject or CreateObjectOnPath method to actually create the object on Atmos.

Raj

222 Posts

June 20th, 2011 08:00

Here's a complete example using C# that reads a file into a byte array and then uses that to create an object on Atmos:

(You'll need to use your own uid, shared secret, host and port information)

using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EsuApiLib;

namespace ConsoleApplication1

{
    class Program
    {
        static void Main(string[] args)
       
     
        {
            string uid = "YOUR_UID";
            string sharedSecret = "YOUR_SECRET";
            string host = "YOUR_ATMOS_IP_OR_DNS";
            int port = YOUR_PORT;

            byte[] array = File.ReadAllBytes("C:\\file.jpg");

            EsuApiLib.Rest.EsuRestApi api = new EsuApiLib.Rest.EsuRestApi(host, port, uid, sharedSecret);

            ObjectPath path = new ObjectPath("/path/to/object.jpg");

            ObjectId oid = api.CreateObjectOnPath(path, null, null, array, null);
                       
            Console.WriteLine(oid);
           
        }
    }
}

16 Posts

June 20th, 2011 22:00

Let me go back to basics. My understanding is like Atmos is also a FileStorage device(FileSystem). Is it right? if so why is that System.Io.file.Copy()is not possible? So for migrating files from existing file system to atmos  we need to use Uploadhelper or read the file as byte[] ? Existing system have many folders and sub folder where all files are kept. we need to migrate those including file attributes.!!!

Let me be more specific. While accessing Atmos using our Client application UI we can make use of the uploadhelper file to copy files. But now we have a file system which has 1000s of folder and sub folder with many files. Now we are trying to create a utility to migrate those files to Atoms. i am working on the utility and for this scenario we need to migrate files using the uploadheader as you mentioned in the above code??If this is the case how to copy directories??Please help!!!!

222 Posts

June 21st, 2011 06:00

Hello,

Atmos is an object storage platform that is best utilized through its RESTful web services API.  If you're using Atmos in your own datacenter then you may have access to the Atmos CIFS interface that will allow you to copy files and folders to it using standard copy operations that don't involve using the REST API.  This CIFS interface is not available from public cloud versions of Atmos including Atmos Online and our service provider partners.

So there are two ways to read/write objects to Atmos:

1.  Using the Atmos REST API

  • Requires using either the Atmos language bindings or using the HTTP REST interface directly

2.  Using the Atmos CIFS/NFS interfaces

  • Only available in local, on-premise deployments of Atmos

How do you plan on using Atmos after you copy files and folders to it?  How will users access content stored on Atmos?

Raj

222 Posts

June 21st, 2011 07:00

You can use the same wrapper for both namespace and object interface methods, but you should focus on the methods that require an object of type ObjectPath argument if your intent is to use the namespace interface.

You can determine which methods are namespace specific by the method name itself.  For instance you should use CreateObjectOnPath rather than CreateObject.  Both methods return an ObjectId, but CreateObjectOnPath interally utilizes the namespace interface.

Other methods are generic and do not apply to a specific interface.  For example SetUserMetadata is not limited to either namespace or object, but rather it can be used with both.  Both interfaces support metadata, ACLs, shareableURLs, etc.

The namespace interface is designed for applications that need file system semantics like directories, user-defined filenames, etc.  The object interface is designed for applications that simply need a unique identifier that is used to subsequently access the object later.

The UploadHelper class is certainly where you should focus efforts in terms of integrating with Atmos for the purpose of migrating files and folders.

Raj

16 Posts

June 21st, 2011 07:00

Hi Raj,

          Thanks for the reply. Actually at the end, users will access atmos using Atmos REST API. But for migrating the files and folders from the existing Filesystem we decided to create a tool which copies files to Atmos using REST. i am trying to create tool which uses the Atmos namspace API so that we will keep the folder structure and copy the files using uploadhelper method as u described in the sample code. So for atmos namespace API same wrapper c# bindings are used or different one...? actually what is the major difference between namespace api and object api.? using namespace api atmos will return object id rht?also is there any other way to migrate file (apart from uploadhelper method) using Rest API.??

Please help !!!! Thanks in advance!!!

16 Posts

June 21st, 2011 08:00

Thanks for the reply raj.. Now i will start working on the tool with all ur inputs... Thanks for replying all the posts!!!! will keep posting my doubts!!!

Thanks again!!!!!

16 Posts

June 22nd, 2011 02:00

Hi Raj,

          Actaully i am trying to copy files using the CreateObjectOnpath. Able to successfully copy the file. But i need to copy all the attributes of the file .Say for eg: i need to copy the created time,modified date time,Archived etc ... of the file which i am trying to migrate to Atmos... How to achieve this? do u have any sample for this? Thanks in advance

222 Posts

June 22nd, 2011 07:00

Hello,

Those attributes are all system attributes which Atmos automatically generates when the object is created, etc.  System attributes in Atmos are read-only so there is no means to modify these values.

However, you can store arbitrary key/value pairs as user metadata for each object.  You could store any required attributes of the object as Atmos user metadata.

Here's an example of using metadata with Atmos:

using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EsuApiLib;

namespace ConsoleApplication1

{
    class Program
    {
        static void Main(string[] args)
       
    
        {

            string uid = "YOUR_UID";
            string sharedSecret = "YOUR_SECRET";
            string host = "YOUR_ATMOS_IP_OR_DNS";
            int port = YOUR_PORT;

            byte[] array = File.ReadAllBytes("C:\\portal.jpg");

            EsuApiLib.Rest.EsuRestApi api = new EsuApiLib.Rest.EsuRestApi(host, port, uid, sharedSecret);

            ObjectPath path = new ObjectPath("/path/to/object/on/atmos.jpg");

            // Create a Metadata object with a key/value pair and set whether it's listable or not
            Metadata meta = new Metadata("original_create_date", "date_value", false);

            // Create a MetadataList object
            MetadataList metalist = new MetadataList();

            // Add the metadata to the list
            metalist.AddMetadata(meta);

            // Use the metadata list when creating the object
            ObjectId oid = api.CreateObjectOnPath(path, null, metalist, array, null);

            // Get the metadata list for a specific object
            MetadataList info = api.GetUserMetadata(path, null);
           
            // Get the specific metadata key/value pair based on key
            Metadata m = info.GetMetadata("original_create_date");

            Console.WriteLine(oid);
            Console.WriteLine(m);
           
        }
    }
}

16 Posts

June 22nd, 2011 23:00

Hi Raj,

Thanks for the reply. Let me  be more specific.Actually i have a file say pdf file with some properties detial like created time, modified time,last accessed etc.

So after migrating that file to Atmos i need those details should be persisted in the atmos. But using AtmosFox  when i view the copied file (Right click ->view properties) the created date time details are todays date time. Is it possible to bring those details???.Actually i need exact replica from the source location?

MetaData:

Actually i tried ur sample  code and it creates file with the specified metadata and those details i can view it by (right clik file->set\view meta data) which has two rows with listable and non listable!!! so does it mean all the file properties details we can save it only in listable or non listable meta data and not in properites?? i mean (Right click ->view properties)???

Did u get wat i am asking u or  am i confusing u?

After copying the file again if i try to copy the same file getting an exception "the file is slaready created"!!! is there any inbuild function to handle this? i mean to skip the copy for already existing file???

Please Help!!!

222 Posts

June 23rd, 2011 06:00

Hello,

I understand the question --- Atmos system metadata which includes attributes such as create time, last access time, etc are read-only.

It is not possible to natively preserve these attributes from the source files while creating objects in Atmos using system metadata.  As you have seen, Atmos sets and updates the system metadata by itself.

The only means of preserving these attributes is using Atmos user metadata which can be listable (indexed) or non-listable (not indexed).

Raj

No Events found!

Top