Select to view content in your preferred language

About attachments in flex viewer

7479
36
Jump to solution
04-21-2015 11:04 AM
EvelynHernandez
Regular Contributor

Hello,

I am developing an app that needs to add an attachment (pdf file) and save it in the arcgis db. Anyone knows how to do that?

My rest service has the attachment value in True, but idk why this code doesnt do it.

This is part of my code:

       myPropLayer.url = "myfeaturelayerurl";

myPropLayer.id = "NewEtaFeature";

  myPropLayer.addAttachment(1,byteArrayToProcess,"ElemetopPDF","pdf",new AsyncResponder(resultado,malresultado));

function resultado():void{

Alert.show("saved");

}

function malresultado():void{

Alert.show("not saved");

}

Mensaje editado por: Evelyn Hernandez. new Question about attachments

0 Kudos
36 Replies
NigelDsouza
Occasional Contributor

Did the debugger work?

0 Kudos
EvelynHernandez
Regular Contributor

No. I installed it and fb still doesnt recognize me the debugger.

It tries to make the connection and got an error with the following msg: "Flash builder cannot locate the requited debugger version of adobe flash player....."

I put that i want to try the debug with the current version and it tries to load the app but nothing happens.

So, i think if anyone can provide me any working example using attachment for PFD and any file will be better,,, (W/o using the attachment inspector)

Thanks for all ur help as always.

0 Kudos
NigelDsouza
Occasional Contributor

Probably the flash player version and the debugger version you installed isn't the same.

For example if you debug in IE and the flash player version is 17 then the debugger exe should be something like

"flashplayer_17_ax_debug.exe" and the link would be something like "Download the Flash Player content debugger for Internet Explorer - ActiveX".

As far as the code is concerned ill send you one soon.

The only thing is maybe the add attachments code block isn't getting executed probably that's why it isnt entering the result or fault methods.

regards,

Nigel.

0 Kudos
EvelynHernandez
Regular Contributor

In fact, i usually do some debug on the apps with Alert.show(); but in this case my point is, the addAttachment method doesnt make anything. Its like the code goes to the line before the addAttch and when go to the addatch line the function doesnt do anything.

Its weird cuz atleast if the adding fails has to go to the fault result, or if its successful, go to the onresult function, but even with those controls doesnt do anything.

About the debug.exe i installed the one u just link me. But i always get the same error. Its strange.

Thanks i will be waiting for ur working example for this. I really appreciate all ur answers

0 Kudos
NigelDsouza
Occasional Contributor

Actually i have successfully done the add attachments task using the android sdk.

So ill prepare one in Flex and send it ASAP.

Give me a day or 2.

Until then you can try and get the debugger to work.. plus it'll make your debugging alot easier

NigelDsouza
Occasional Contributor

Hi Evelyn,

I have prepared a small widget for you..

like I said your code is perfect.. just change

the "AttachmentEvent" event into "FeatureEditResult"

so this "function resultado(event:AttachmentEvent):void" would look like

function resultado(event:FeatureEditResult):void

However you can use my widget as a reference..

I did get a successful result.

I have used an online ArcGIS service in the example that uploads a txt file.

Here's a Google drive link to the following widget. You can directly included it in your app and run it .

Test.zip - Google Drive

If you get a successful result you can navigate to the featureLayer link in yout browser "Feature Layer: Incidents (ID: 0) " append the objectid passed as a parameter, so your link would look like this

"http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/SanFrancisco/311Incidents/FeatureServer/0..."

hit enter and you should be navigated to the record. Then click on the Attachmentinfos link to view your attachment.

I hope this helps you.

Regards,

Nigel..

0 Kudos
EvelynHernandez
Regular Contributor

I will try it inmediately!! Thank for all ur effor

0 Kudos
EvelynHernandez
Regular Contributor

Thanks a lot! i already tried it with my rest srv and it works perfectly

U rock !

0 Kudos
NigelDsouza
Occasional Contributor

Most welcome

Where was the error at?

Did the sample I sent help you?

Regards,

Nigel

0 Kudos
EvelynHernandez
Regular Contributor

Yes ur example works perfectly. the error was in the onresult maybe and the addatch sentence.

I have another question. If u want to do a delete or update on one especified attch how will it be the featurelayer.addattachment sentence for both cases?

Or i have to use another method to do that?

Thanks

0 Kudos