How to Upload a Slide

88 views
Skip to first unread message

ulfat

unread,
Jun 11, 2009, 8:21:26 AM6/11/09
to SlideShare Developers
I am using the ASP.NET 1.1. I am having problem while uploading a
Slide. Will the parameter "slideshow_srcfile" be an absolute URL of a
slide.It has not been documented properly.

Please help regarding this.

sri prasanna

unread,
Jun 11, 2009, 8:58:11 AM6/11/09
to slideshare...@googlegroups.com

ulfat

unread,
Jun 15, 2009, 2:11:26 AM6/15/09
to SlideShare Developers
Hi!

Thanks but Can you provide me some code of .NET.

Regards
Ulfat

On Jun 11, 5:58 pm, sri prasanna <macho...@gmail.com> wrote:
> Hi Ulfat,
> Hope this helpshttp://groups.google.com/group/slideshare-developers/browse_thread/th...
>
> Regards,
> Sri Prasanna. K
> Blog:http://sprasanna.com
>

sri prasanna

unread,
Jun 15, 2009, 3:40:06 AM6/15/09
to slideshare...@googlegroups.com
Hi Ulfat,

There is one .NET wrapper for SlideShare api. But I think its for API v1 but still you can use it. You can get that from here http://groups.google.com/group/slideshare-developers/files


Regards,
Sri Prasanna. K
Blog: http://sprasanna.com



ulfat

unread,
Jun 15, 2009, 4:09:59 AM6/15/09
to SlideShare Developers
Hi, thanx for quick reply.

actually i have converted this "DotNetUtil.zip" to 1.1.
for the function "executePostCommand" I have chanegd the line of code

webRequest.ContentType = "application/x-www-form-urlencoded";
to
webRequest.ContentType = "application/multipart/form-data";

.Now I am using this dll into my application.I have a page
"UploadFile.aspx". In that page i have a fileupload control which name
i have to "slideshow_srcfile". For calling "executePostCommand"

I have written my own function as:

Public Function UploadSlide(ByVal slideName As String, ByVal SlideSRC
As String)

Dim parameters As String = ((("api_key=" & api_key &
"&ts=") + timestamp & "&hash=") + CalculateSHA1(shared_secret +
timestamp, Encoding.UTF8) & "&slideshow_title=") + slideName
o &= parameters

Dim reader As String = executePostCommand("http://
www.slideshare.net/api/2/upload_slideshow", parameters)

End Function

but when i call the function UploadSlide().
Slide is not uploaded.

Please help if i am doing something wrong.

Regards

On Jun 15, 12:40 pm, sri prasanna <macho...@gmail.com> wrote:
> Hi Ulfat,
>
> There is one .NET wrapper for SlideShare api. But I think its for API v1 but
> still you can use it. You can get that from herehttp://groups.google.com/group/slideshare-developers/files
>
> Regards,
> Sri Prasanna. K
> Blog:http://sprasanna.com
>

sri prasanna

unread,
Jun 15, 2009, 11:28:44 AM6/15/09
to slideshare...@googlegroups.com
I remember same thing happened few months back you can check the conversation here http://groups.google.com/group/slideshare-developers/browse_thread/thread/ede5626c0deb1a96

ulfat

unread,
Jun 18, 2009, 3:58:08 AM6/18/09
to SlideShare Developers
I want to use .net code. I had found a function which worked for other
but i ge "invalid extension error" when i try this code.


private static string executeUploadCommand(string parameters, string
fname, string ctype, byte[] file)
{
string boundary = "----WhatIsTheBoundary";

if (api_key == null || shared_secret == null || timestamp
== null)
return "Keys must be initialized first";

WebRequest webRequest = WebRequest.Create("http://
www.slideshare.net/api/1/upload_slideshow");
webRequest.ContentType = "multipart/form-data; boundary="
+ boundary;
webRequest.Method = "POST";
webRequest.Timeout = 60000;

string[] keys = parameters.Split(new char[] { '&' });

// Set the body of request
StringBuilder sb = new StringBuilder();
sb.Append("--");
sb.Append(boundary);
sb.Append("\r\n");
for (int i = 0; i < keys.Length; i++)
{
string[] param = keys[i].Split(new char[] { '=' });
sb.Append("Content-Disposition: form-data; name=\"" +
param[0] + "\"");
sb.Append("\r\n");
sb.Append("\r\n");
sb.Append(param[1]);
sb.Append("\r\n");
sb.Append("--");
sb.Append(boundary);
sb.Append("\r\n");
}
sb.Append("Content-Disposition: form-data; name=\"" +
"slideshow_srcfile" + "\"");
sb.Append("; filename=\"" + fname + "\"");
sb.Append("\r\n");
sb.Append("Content-Type:" + ctype);
sb.Append("\r\n");
sb.Append("\r\n");

string message = sb.ToString();

byte[] bytes = Encoding.UTF8.GetBytes(message);
byte[] msgbyte = new byte[bytes.Length + file.Length];

Array.Copy(bytes, msgbyte, bytes.Length);
Array.Copy(file, 0, msgbyte, bytes.Length, file.Length);

// Ending Boundry
StringBuilder sb2 = new StringBuilder();
sb2.Append("--");
sb2.Append(boundary);
sb2.Append("--");
string message2 = sb2.ToString();

byte[] bytes2 = Encoding.UTF8.GetBytes(message2);
byte[] msgbyte2 = new byte[bytes2.Length +
msgbyte.Length];

Array.Copy(msgbyte, msgbyte2, msgbyte.Length);
Array.Copy(bytes2, 0, msgbyte2, msgbyte.Length,
bytes2.Length);

Stream os = null;
try
{
webRequest.ContentLength = msgbyte2.Length;
os = webRequest.GetRequestStream();
os.Write(msgbyte2, 0, msgbyte2.Length);
}
catch (WebException ex)
{
return ex.ToString();
}

finally
{
if (os != null)
{
os.Close();
}
}

try
{
WebResponse webResponse = webRequest.GetResponse();
if (webResponse == null)
{ return null; }
StreamReader sr = new StreamReader
(webResponse.GetResponseStream());
return sr.ReadToEnd().Trim();
}
catch (WebException ex)
{
return ex.ToString();
}
}

This code was written by Blumpy.tr .

I am passing the type of file to be uplloaded and bytes of file .

Regards



On Jun 15, 8:28 pm, sri prasanna <macho...@gmail.com> wrote:
> I remember same thing happened few months back you can check the
> conversation herehttp://groups.google.com/group/slideshare-developers/browse_thread/th...

sri prasanna

unread,
Jun 18, 2009, 4:54:32 AM6/18/09
to slideshare...@googlegroups.com
Allowed extensions are
Presentations: PowerPoint - ppt, pps, pot, pptx, potx, ppsx; OpenOffice - odp, pdf; Apple Keynote - key, zip or pdf.
Documents & Spreadsheets: Microsoft Office - doc, docx, rtf, xls; OpenOffice - odt, ods, pdf; iWork Pages.


Regards,
Sri Prasanna. K
Blog: http://sprasanna.com



Ulfat Hussain

unread,
Jun 18, 2009, 5:13:35 AM6/18/09
to slideshare...@googlegroups.com
Hi

I am using ppt which is allowed extension.
I think there is something wrong with the code.

Regards
Ulfat

ulfat

unread,
Jun 19, 2009, 12:35:28 AM6/19/09
to SlideShare Developers
Hi,

for content type of file in the above code it is set to

"application/vnd.ms-powerpoint"
is it right or we have to change it.
"multipart/formdata" is alsonot working.

Any suggestion.
Regards
Ulfat

On Jun 18, 1:54 pm, sri prasanna <macho...@gmail.com> wrote:
> Allowed extensions are
> *Presentations*: PowerPoint - ppt, pps, pot, pptx, potx, ppsx; OpenOffice -
> odp, pdf; Apple Keynote - key, zip or pdf.
> *Documents & Spreadsheets*: Microsoft Office - doc, docx, rtf, xls;
> OpenOffice - odt, ods, pdf; iWork Pages.
>
> Regards,
> Sri Prasanna. K
> Blog:http://sprasanna.com
>

sri prasanna

unread,
Jun 19, 2009, 2:11:40 AM6/19/09
to slideshare...@googlegroups.com
Hi,

I don't know much about .NET. Here is the code which I have written for upload in PHP. Hope this helps.


Regards,
Sri Prasanna. K
Blog: http://sprasanna.com



upload.php

Ulfat Hussain

unread,
Jun 22, 2009, 2:20:29 AM6/22/09
to slideshare...@googlegroups.com
Hi,
thanx. Yor are posting a form and it will surely be posted with all controls and no problem will occur. in .net we have to make a request and then add all required data to be added in this request and this request will be served as if a form is posted.WE get response of request and check  it.Every time  I get response with error ("invalid file extension"). I will try to solve this.Or I may use a form like yours in my ASPX page and then try .Anyhow thanks for your help.

Regards
Ulfat Hussain

ulfat

unread,
Jun 25, 2009, 3:29:28 AM6/25/09
to SlideShare Developers
hi.

I had solved my problem from this groups. But I have to ask one thing.
you have given link
http://groups.google.com/group/slideshare-developers/browse_thread/thread/b3a267ce4bf6275a/6a418d43ebc65ac5
from where is copied following zip
Slideshare Upload Sample Code.zip

it contains an html form which is posted to slideshare api upload
page.Whenever i use it, after it uploads the slide or gives any error
message.it is displayed.I want to accomplish the thing that when a
slide is uploaded i don not get response but instead window is closed
so that user cannot see any response from API. I dont kow about this.
but is it possible?

Regards
Ulfat Hussain

On Jun 11, 5:58 pm, sri prasanna <macho...@gmail.com> wrote:
> Hi Ulfat,
> Hope this helpshttp://groups.google.com/group/slideshare-developers/browse_thread/th...
>
> Regards,
> Sri Prasanna. K
> Blog:http://sprasanna.com
>

sri prasanna

unread,
Jun 25, 2009, 8:44:28 AM6/25/09
to slideshare...@googlegroups.com
Hi,

Yeah it is possible. The scenario in that file is its just a html file and the response are manipulated so the browser just shows the returned xml. You can do the same in other way. Write a html file so that it will upload the file first to your asp file in the server. Then the asp file uploads the file to slideshare server. After upload an xml file will be returned with messages (success or error) it can be manipulated by the asp page and show custom message to user like "Slideshow uploaded successfully" or close user's upload window by sending a small javascript snippet.

Regards,
Sri Prasanna. K
Blog: http://sprasanna.com



Ulfat Hussain

unread,
Jun 29, 2009, 3:50:25 AM6/29/09
to slideshare...@googlegroups.com
Hi thanks.
I have a different scenario. I open a form which  is an aspx Page(slideshareuploadform.aspx).
It contains a for tag by default which is
"<form id='' runat=server" an other attributes >
"
I have placed another form  below this form
"
<form id='some id' action='to slideshareapi' method=post' enctype='multipart/form-data'>

in this form I have a filed which contains api key,other contains secret,one for entering username and one for password,one for slidetitle, one is uploadfilecontrol used for uploading slide.all fields name are set to those names required by slideshare api.
thers is one button of type "submit".after entering information and selecting slide I am returned te slideid of uploaded slide.
"

so how can i Use another asp page as you have saind in your email the following lines
""You can do the same in other way. Write a html file so that it will upload the file first to your asp file in the server. Then the asp file uploads the file to slideshare server."".

Please explain a little bit. I am confused about this sentence.because I am already on an asp.net page which is posting data to slideshare api.

Regards
Ulfat Hussain

sri prasanna

unread,
Jun 29, 2009, 3:57:21 AM6/29/09
to slideshare...@googlegroups.com
What I have written is one way of doing it and its actually pretty simple.

1) Create a normal html file with a form to get file and some related data from user like title etc.
2) in "action" attribute of the "form" point it to some asp file like "upload.aspx"
3) So now when user clicks submit button the data are sent to upload.aspx.
4) Now you can upload that file which you have received from the user to slideshare with your credentials.
5) Now slideshare will return you a simple xml file saying whether the upload is successful or not.
6) According to the message you get back from slideshare you can redirect the user or tell him whether the upload is successful or not.


Regards,
Sri Prasanna. K
Blog: http://sprasanna.com



Ulfat Hussain

unread,
Jun 29, 2009, 4:17:21 AM6/29/09
to slideshare...@googlegroups.com
Thanks.Its correct.
But my problem is different.
Previously I was using .net code for uploading.I had to pass all the parameters to a class along with file(i had to convert this file into Byte() ), and it returned a response which i could manipulate. But it was not working for 2007 slides.
Then I used the code  which you specified and is mentioned in earlier posts.This calculates hashtime using javascript.and simply posts the form. When I used this , 2007 slides were also uploaded but in this case i cannot get response.
Now if I have an html form then i will be posting my file control to aspx page alongwith other parameters. In this aspx page if  I again use code (Using HTTP webrequest ) then it would be same as I was using previous code to upload file. So agian it will not upload office 2007 file.
Or what you suggest what to do on this aspx page.What can be done on this page so that we can upload slide without making HTTPWEbrequest object and get response.

Regards
Ulfat Hussain

sri prasanna

unread,
Jun 29, 2009, 5:13:34 AM6/29/09
to slideshare...@googlegroups.com
Ah, You can do it in different ways. For example you can upload file through an iframe and can manipulate the return data. Or you can get some javascript libraries to do that. My personal favorite is jQuery and it has got lot of plugins to accomplish this
http://www.google.com/search?hl=en&safe=off&client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial&hs=9pX&q=jquery+file+upload&aq=f&oq=&aqi=



Regards,
Sri Prasanna. K
Blog: http://sprasanna.com



Ulfat Hussain

unread,
Jun 30, 2009, 11:58:57 PM6/30/09
to slideshare...@googlegroups.com
Hi!
You have written
"For example you can upload file through an iframe and can manipulate the return data".
Please explain this point, I cannot comprehend this.


Thanks

Regards
Ulfat Hussain.

sri prasanna

unread,
Jul 1, 2009, 1:54:27 AM7/1/09
to slideshare...@googlegroups.com
This page will give you a nice understanding and they have a real good demo of that
http://www.openjs.com/articles/ajax/ajax_file_upload/


Regards,
Sri Prasanna. K
Blog: http://sprasanna.com



Reply all
Reply to author
Forward
0 new messages