Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I use Youtube API to upload videos on youtube. I read the documentation here, but there is one problem. I want to use FileUpload asp.net control, so users can easily upload file. But youtube api requires full path of the file and FileUpload control doesn't support it of security reasons. So I tried to solve it this way:

 Dim fileName As String = System.IO.Path.GetFileName(FileUpload1.PostedFile.FileName)
        FileUpload1.SaveAs(Server.MapPath("~/Uploads/") + System.IO.Path.GetFileName(FileUpload1.FileName))
        Dim FullPath As String = Server.MapPath("~/Uploads/") + System.IO.Path.GetFileName(FileUpload1.FileName)     

        Dim newVideo As New Video()

        newVideo.Title = "Test video"
        newVideo.Tags.Add(New MediaCategory("Games", YouTubeNameTable.CategorySchema))
        newVideo.Keywords = "test 1 , test 2"

        newVideo.Description = "test 3 test 4"
        newVideo.YouTubeEntry.[Private] = False
        newVideo.Tags.Add(New MediaCategory("tag 1, tag 2", YouTubeNameTable.DeveloperTagSchema))

        newVideo.YouTubeEntry.Location = New GeoRssWhere(37, -122)


        newVideo.YouTubeEntry.MediaSource = New MediaFileSource(FullPath, FileUpload1.PostedFile.ContentType)

     Dim createdVideo As Video = request.Upload(newVideo)

I save the vide file in Uploads folder in my application and then get the path by Server.MapPath. It works like this on my computer, on localhost. But when it will be on web server (web hosting), it won't work.

How do you solve this problem with FileUpload in this certain case? Please help me, I've been searching for the answer for 3 days.

share|improve this question
I think you can upload a FileStream (FileUpload1.PostedFile.InputStream) using Youtube-API v3. This blog might give you insight: helicoder.wordpress.com/2013/07/19/… – mostruash Jul 20 at 13:23

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.