Creating media resources
Added by IBM contributorIBM | Edited by Claudia R Elbourn on June 15, 2015
Rate this article 1 starsRate this article 2 starsRate this article 3 starsRate this article 4 starsRate this article 5 stars

When you upload a file to a blog, the server creates a media resource entry to represent the file. To create a media resource, post the file to the blog using the HTTP POST method.
The types of files, and the maximum sizes of the files that can be uploaded to a blog is defined by the Blogs administrator. See the Administering Blogs section of the IBM® Connections product documentation for more details.

In addition to creating a media resource entry to represent the file, the server also creates an entry called a media link entry that contains information about the file. You can use the media link entry to separately retrieve metadata of the media resource.

Note: Draft authors are not allowed to post media content to a blog.

Provide a data file in one of the following ways:

  • Specify a JPEG file as the POST data. For example:
  • Use the HTTP entity-header of Slug to specify the file. (See the Atom Publishing Protocol specification for allowed values of this header.) For example, specify the slug as follows:

You must also specify the content type of the file. For example, if the file has a JPEG extension, specify the content type as follows:

content-type:image/jpeg 

Input
Method URI Description
POST /blogs/{communityUuid}/api/media Value of the href attribute of the <collection> element that has a child <title> element with a value of Media Entries in the user's service document.
Name Type Optional Description
communityUuid
string No The UUID of the community that contains the blog..
Name Type Optional Description
X-LConn-RunAs
string Yes The value should be in such format: userid=<user ext id>,username=<user name>,useremail=<user mail> .
This header enables impersonation and must works with Blogs admin user to authenticate request. If the user does not exists, an inactive user will be created with specified userid , username and usermail. If the user exists, username and useremail can be omitted.
eg:userid=BFB5FDCB-B0E2-408A-A351-09103D8D5527,username=xxxxxx,useremail=xxxx@cn.ibm.com
Output
Name Type Optional Description
Location
string No Link to the media link entry created by the server for the file. You can use the web address specified here to obtain information about the file by retrieving the media link entry. Once retrieved, you can use the edit-media link in the media link entry to update the media resource file itself.
Code Description
201
Indicates that the file was successfully uploaded. If an error occurs, this header contains one of the error codes.
401
Unauthorized. Returned when no authenticated user or no userid, email, or key parameter are provided on the request.
404
Not Found.
409
Conflict: Indicates that a file with the same file name already exists in the upload folder. To resolve the problem, either assign a unique name to the request's "slug" header or do not assign anything to this header and let the server generate a file name. Note that if you let the server generate the name, it uses the blog handle and time stamp for the file name, and might be difficult to recognize. Also, if you are using a third-party blogging tool, the server automatically takes the file name and assigns that to the slug header, so if you post the file twice in the third-party blogging tool without changing the file name after the first post, you will get a 409 error the second time.
References
Examples
POST /hostname/path/to/media/resources HTTP/1.1

	Host: ...

	Authorization: ...

	Content-Type: image/jpg

	Content-Length: 6730

POST /hostname/path/to/media/resources HTTP/1.1

	Host: ...

	Authorization: ...

	Slug: Gulls

	Content-Type: image/jpg

	Content-Length: 6730