This project has moved and is read-only. For the latest updates, please go here.

Web Upload Photo

Jul 11, 2007 at 4:09 PM
i am trying to upload photos from my personnal website to my flickr account:
basically i use

flickr.AuthCalcWebUrl(FlickrNet.AuthLevel.Write )
string photoid = flickr.UploadPicture(filename)

authentication is good, the token is good, the file exist, i have no exception when i upload the file, but photoid is empty and
the photo is not uploaded.

MyWebsite is hosted with medium trust but i have no message of security permission.

Do you have an idea of the problem?
Jul 12, 2007 at 10:47 AM
Medium Trust is likely to be the problem, but it usually gives you some form of error message, even if it doesn't mean much. I'll double check the source code but I don't think I trap any exceptions.
Jul 13, 2007 at 9:57 AM
i check the code and it seems to be the code
new FileStream(path, FileMode.Open , FileAccess.Read, FileShare.Write );
that throw a Permissions.FileIOPermission because of the medium trust.

I didn't find an alternative to FIleStream for we have to send binaries.

Someone has an idea?
Jul 13, 2007 at 10:53 AM
Well that error usually means you don't have permission to read the file.

Try creating your own FileStream object with different permissions and passing that into the UploadPicture method (it accepts streams as well).

Double check the filename is the correct filename, and not the filename on the client (if you are uploading a file).
Jul 13, 2007 at 1:43 PM
thanks for your reply.
I verify that i have the right to read the file.
I have been a little bit further.
In medium trust you can't use FileStream whatever the permissions.
Instead of using it, i've tried with a binaryreader
BinaryReader stream = new BinaryReader(File.Open(path, FileMode.Open));
and i passed through security permissions.
(there is a small modification to do: stream.Length to stream.BaseStream.Length)
i test it between two websites i have on differents servers, and it works.

When i try with flickr, it still doesn't work but i have no exception.
As i don't know how they handle our webrequest, i can't go ahead.

any idea?
Jul 25, 2007 at 9:53 AM
You are still using a FileStream, even if you don't think you are.

File.Open returns a FileStream object.

I still have no idea what the cause of the problem might be.

Do other flickr operations work? (like a PhotosSearch operation?)

Does the following code snippet work?

HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create("");
req.method = "POST";
HttpWebResponse res = (HttpWebResponse)req.GetResponse();
StreamReader sr = new StreamReader(res.GetResponseStream());