Upload Photo Filesize was zero

Topics: Developer Forum
Mar 8, 2012 at 6:03 PM

Hello All,

I recently downloaded the Flickr.net and I am trying to Upload a Photo.

But no matter what I do, I always get the same error "Filesize was zero (4)"

Do you know what this means?

 

            this.flickr.UploadPictureAsync(stream, fileName, title, description, tags, isPublic, isFamily, isFriend, ContentType.Photo, SafetyLevel.Safe, HiddenFromSearch.Visible, p =>                {                    FlickrUploadArgs flickrUploadArgs = new FlickrUploadArgs();
                    flickrUploadArgs.flickrResult = p;
                    this.OnUploadCompleted(flickrUploadArgs);                });

Coordinator
Mar 8, 2012 at 6:53 PM

How are you creating your stream object?

Sam

Mar 8, 2012 at 6:57 PM

I collect the Images using the PictureCollection from the XNA framework, then I get the stream using the Method GetImage from the Picture Class.

Thanks for the fast reply

Coordinator
Mar 8, 2012 at 6:59 PM

Is this in WP7?

Mar 8, 2012 at 7:01 PM

Yes, It is.

Mar 8, 2012 at 7:44 PM

I changed the ConvertNonSeekableStreamToByteArray method and It appears to work.

Now I am getting another problem. Filetype was not recognised

Thanks,

Diego

Coordinator
Mar 26, 2012 at 12:39 PM

Did you ever get anywhere with this? I've never had any problem with uploads in WP7, but I've always been working directly with the camera task to get my images.

Perhaps if you could provide a bit more code around how you obtain the stream specific to the XNA framework PictureCollection I might be able to reproduce the problem.

Mar 26, 2012 at 12:43 PM

Thanks fine by now....

I fixed the problem here it worked fine.

Probably I did something wrong that I cant even remember now.

Thanks for the reply.

Everything is working fine. Good work :) 

Apr 4, 2012 at 9:37 AM

hello, do you still remember how to fix this problem? I have the same problem.

I get the stream like this:

private void photoChooser_Completed(object sender, PhotoResult e)
        {
            try
            {
                if (e.TaskResult == TaskResult.OK)
                {
                   
                    BitmapImage bitmap = new BitmapImage();
                    bitmap.SetSource(e.ChosenPhoto);
                    this.UploadImage.Source = bitmap;

                      //this is the stream.
                       uploadSelectViewModel.Stream = e.ChosenPhoto;
                }
            }
            catch (Exception a)
            {
                MessageBox.Show(a.ToString());
            }

        }

Coordinator
Apr 4, 2012 at 9:43 AM

It is likely that using the stream to create the bitmap has moved the stream to the end.

If the stream that ChosenPhoto returns is seekable you could try setting e.ChosePhoto.Position = 0 before adding it to the view model (or even better reset this when you do the upload).

Apr 4, 2012 at 10:06 AM

I appricate for you support, yes, you are right, I remove this, it works fine, but I need it show it the phone when picture is selected.

Could you please explain to me how to reset it?  in the property of e.ChosePhoto don't has Position.

 //BitmapImage bitmap = new BitmapImage();
                    //bitmap.SetSource(e.ChosenPhoto);
                    //this.UploadImage.Source = bitmap;

Coordinator
Apr 4, 2012 at 10:19 AM

e.ChosenPhoto is a Stream class. Stream.Position is a standard property of that class.

http://msdn.microsoft.com/en-us/library/microsoft.phone.tasks.photoresult.chosenphoto(v=vs.92).aspx

http://msdn.microsoft.com/en-us/library/system.io.stream.position(v=vs.95)

Apr 4, 2012 at 11:40 AM

You are great!It works fine.many thanks.