Post

2 followers Follow
0
Avatar

.NET Client attaching files on item

Hey everyone, 

I'm building a nice app with the .NET client. But i'm running with some questions.

I've noticed that in the Podio Building Blocks there's no File Upload block, and the Image only supports image mime type formats. It would be great that in future you could support a file upload block.

 

Going other way around I'm trying to upload the files and sending them as attachments on a Item object. Alltought it always throws me a null reference exception. I'm I missing something here?

 

HttpPostedFile file = HttpContext.Current.Request.Files[requestFile];

if (file != null && file.ContentLength <= 0) continue;

Byte[] data = new byte[file.ContentLength];

file.InputStream.Read(data, 0, file.ContentLength);

var fileAttachment = client.FileService.UploadFile(data, file.FileName, file.ContentType);

if (fileAttachment.FileId != null) fileIds.Add((int) fileAttachment.FileId);

item.Files.Add(fileAttachment); // THROWS EXCEPTION

 

Also in the settings of my App in Podio I've checked the option 'Files can be attached'.

Thanks, 

Joao.

Joao Antao Answered

Please sign in to leave a comment.

4 comments

0
Avatar

The .NET client is not as clever and developer-friendly as you might expect. Some things has to be done a bit more manually, and this is one example.

Calling item.Files.Add(fileAttachment) will not help you actually attaching a file to an item. The Files area has an operation for attaching a file to an item, but it's not implemented in the .NET client yet. You can however still call the operation through the .NET client. This is one example of how to do a POST request using the underlying PodioRestHelper.

You can also update the item with one or more file_ids. If you look here and here it should give the general idea.

Casper Fabricius 0 votes
0
Avatar

Hey Casper, thanks for your fast answer.

Do you know if it's gonna be implemented soon?

 

Joao Antao 0 votes
0
Avatar

Probably not. The client was contributed by a Podio user, and we don't have any dedicated .NET people in our own team.

However, this shouldn't stop from doing what you want. You just have to write slightly more code than you would have else-wise. People were using the Podio API from .NET before any .NET client existed at all.

Casper Fabricius 0 votes
0
Avatar

Yes, probably will do it myself soon and extend it to the .NET Client.

 

Thanks.

Joao Antao 0 votes