Unsolved
This post is more than 5 years old
12 Posts
0
13271
May 23rd, 2009 07:00
Uploading a file on Atmos
Hello Everyone,
I am new to programming and FLEX,Can any one please help me or give me an example on how to upload data to Atmos using the FLEX Bindings.
Thanks in advance...
0 events found
No Events found!


JasonCwik
281 Posts
0
May 28th, 2009 09:00
Hi Raghu,
For the sample code in the document, the pathinput should be filled with the path inside atmos (a.k.a. 'namespace path'). For example /root/myfiles/
Hemanth2
12 Posts
0
June 2nd, 2009 03:00
Hi Jason,
This is a lot of info and is very hepfull for me , but i have not yet uploaded anything to atmos .
As per the example code you have provided is
serviceObject.listDirectory(new ObjectPath(pathInput.text), handleResponse, null);
here ListDirectory returns all the objects in the specified directory as an array of DirectoryEntry objects but it would be helpful for me if you can show me an example on how to create a new object in the cloud and upload a file using Uploadhelper ?
Thank you for the response ,
Hemanth
JasonCwik
281 Posts
0
June 7th, 2009 11:00
Hi Hemanth,
Attached is a simple application that will upload a file to Atmos. You will need FlexBuilder 3.0.2 (Flex 3.3 SDK) and Flash 10 for it to work.
Regards,
Jason
1 Attachment
uploadtest.mxml
JasonCwik
281 Posts
0
June 9th, 2009 07:00
Are you seeing that in your debug window or in the application? I've seen it in the debug logs long after requests to Atmos are done. It does not appear to affect application performance. I believe it is a bug that occurs in Flash when it tries to dispose the socket used for the request.
JasonCwik
281 Posts
0
June 10th, 2009 12:00
Actually, I was wrong. It's hourly. See: https://community.emc.com/thread/3525?tstart=0
JasonCwik
281 Posts
0
June 10th, 2009 12:00
From what I've heard, the disk usage does not immediately update. It may take a day or so to see it in the dashboard.
I've attached an updated sample app with 'check upload' and 'list directory' buttons. After upload, you can press the 'check upload' button to see if the file exists (and its size) and then click list directory to view the directory contents.
1 Attachment
uploadtest.mxml
cna2
2 Posts
0
June 15th, 2009 07:00
shridevi -
If you created the objects via the namespace, you should be able to do a ReadObject on the directory to get the ObjectIDs of the files in the directory.
/Chris
JasonCwik
281 Posts
0
June 16th, 2009 16:00
Hi Raghu,
All of the functions in the Flex API are asynchronous. They return immediately and give you results later through the callback.
For readObject, the callback state object will contain a ByteArray in the result field. For example:
public function readObjectCallback( state:EsuCallbackState ):void {
if( !state.wasSuccessful() ) {
// Handle error
Alert.show( state.getError().message, "Error reading object", 4, this );
return;
}
var data:ByteArray = ByteArray( state.result );
// Process data
}
JasonCwik
281 Posts
0
June 17th, 2009 07:00
Can you attach your whole program? It sounds like your file object is null. You have to initialize the FileReference object before you can save().
JasonCwik
281 Posts
0
June 19th, 2009 15:00
It's definitely the FileReference. The code in onDownloadCompletion should look more like this:
private function onDownloadCompletion (state:EsuCallbackState):void {
if( !state.wasSuccessful() ) {
Alert.show( state.getError().message, "Error Downloading", 4, this );
return;
}
d_file = new FileReference();
d_file.save(ByteArray(state.getResult()), downloadfile.text);
}
In addition, I would recommend adding event handlers to d_file before calling save() so you can get notified that the save is complete and/or failed. See onUploadClick() for how to addEventListener.
Hemanth2
12 Posts
0
June 28th, 2009 04:00
private function onSave():void{
var esu:EsuApi = new EsuRestApi( serverText.text, 80, uidText.text, secretKeyText.text );
var id:ObjectId = new ObjectId( "4980cdb2a110105804980d83b1853504a4748c2f02e7");
var downloadHelper:DownloadHelper = new DownloadHelper( esu );
downloadHelper.addEventListener( Event.COMPLETE, onComplete );
var data:ByteArray = new ByteArray();
downloadHelper.readObject( id, data );
}
function onComplete( event:Event ) {
var downloadHelper:DownloadHelper = DownloadHelper( event.target );
var data:ByteArray = ByteArray( downloadHelper.stream );
// Do something with the data
}
I have downloaded file from atmos and it is stored in data(ByteArray ), can anyone tell me how to store this content into text fle ??
Thanks,
Hemanth
JasonCwik
281 Posts
0
June 29th, 2009 07:00
Hi Hemanth,
With Flex 3.2 and Flash Player 10, you can use the FileReference class to save a byte array to a file.
d_file = new FileReference();
// register event handlers for complete and error
d_file.save( byteArray, suggestedFilename );
http://livedocs.adobe.com/flex/3/langref/flash/net/FileReference.html#save()
JasonCwik
281 Posts
0
July 28th, 2009 06:00
Hi Raghu,
Unfortunately, it looks like you're at the mercy of the Flash sandbox here and this is the best way to do it. The only other alternative I can think of would be to write an Air application and pass the download operation to the Air application from Flash. You're not sandboxed once you get into Air and can read and write files at will.
http://livedocs.adobe.com/flex/3/html/help.html?content=Part2_DevApps_1.html