Reworked file uploads to include server-generated thumbnails
This commit is contained in:
@@ -103,41 +103,36 @@ namespace matrix{
|
||||
//NOTE alias equivalents just give the uploaded file a name other than the filename.
|
||||
/*
|
||||
* Upload a file as a raw file.
|
||||
* Takes filename as argument.
|
||||
* Takes file data as argument.
|
||||
* Returns: file_info struct containing the url of the file on the homeserver.
|
||||
* Note check the file_info::fileurl field to check if the upload succeeded.
|
||||
*/
|
||||
file_info upload_file(const raii::string_base& filename)const;
|
||||
file_info upload_file(const raii::string_base& filename, const raii::string_base& alias)const;
|
||||
file_info upload_file(const file_details& file)const;
|
||||
|
||||
/*
|
||||
* Upload a file as an image.
|
||||
* Note: requires FreeImagePlus to treat the file as an image, otherwise will just upload as a raw file.
|
||||
* Returns: image_info struct containing the url of the image on the homeserver.
|
||||
* Note check the image_info::fileurl field to check if the upload succeeded.
|
||||
*/
|
||||
image_info upload_image(const raii::string_base& filename)const;
|
||||
image_info upload_image(const raii::string_base& filename, const raii::string_base& alias)const;
|
||||
image_info upload_image(const image_details& file)const;
|
||||
|
||||
/*
|
||||
* Upload a file as a video.
|
||||
* Note: requires ffmpeg to treat the file as a video, otherwise will just upload as a raw file.
|
||||
* Upload data as a video.
|
||||
* Returns: video_info struct containing the url of the image on the homeserver.
|
||||
* Note check the video_info::fileurl field to check if the upload succeeded.
|
||||
*/
|
||||
video_info upload_video(const raii::string_base& filename)const;
|
||||
video_info upload_video(const raii::string_base& filename, const raii::string_base& alias)const;
|
||||
video_info upload_video(const video_details& file)const;
|
||||
/*
|
||||
* Upload a file as an audio file.
|
||||
* Note: requires ffmpeg to treat the file as a audio, otherwise will just upload as a raw file.
|
||||
* Returns: audio_info struct containing the url of the image on the homeserver.
|
||||
* Note check the audio_info::fileurl field to check if the upload succeeded.
|
||||
*/
|
||||
audio_info upload_audio(const raii::string_base& filename)const;
|
||||
audio_info upload_audio(const raii::string_base& filename, const raii::string_base& alias)const;
|
||||
audio_info upload_audio(const audio_details& file)const;
|
||||
|
||||
bool create_thumbnail(image_info& info)const;
|
||||
bool create_thumbnail(video_info& video)const;
|
||||
private:
|
||||
raii::rjp_string _upload_file(raii::filerd& fp, const raii::curl_llist& header)const;
|
||||
file_info _upload_file(const file_details& file, const raii::curl_llist& header)const;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -52,6 +52,7 @@ namespace matrix{
|
||||
const raii::string& whoami(void)const;
|
||||
const raii::string& displayname(void)const;
|
||||
const raii::string& profile_picture(void)const;
|
||||
raii::string file_thumbnail(const raii::string_base& homeserver, const raii::string_base& fileurl, int width, int height, const raii::string_base& method)const;
|
||||
raii::string logout(const raii::string_base& homeserver, const raii::string_base& access_token)const;
|
||||
raii::string sync(const raii::string_base& homeserver, const raii::string_base& access_token, const raii::string_base& next_batch, const raii::string_base& timeout)const;
|
||||
raii::string power_level(const raii::string_base& homeserver, const raii::string_base& access_token, const raii::string_base& roomid)const;
|
||||
|
||||
@@ -25,6 +25,19 @@
|
||||
|
||||
namespace matrix{
|
||||
|
||||
struct file_details{
|
||||
raii::string data;
|
||||
raii::string name;
|
||||
};
|
||||
struct image_details : public file_details{
|
||||
int width, height;
|
||||
raii::string mimetype;
|
||||
};
|
||||
struct video_details : public image_details{};
|
||||
struct audio_details : public file_details{
|
||||
raii::string mimetype;
|
||||
};
|
||||
|
||||
struct file_info{
|
||||
raii::rjp_string fileurl;
|
||||
raii::string filename;
|
||||
@@ -37,6 +50,7 @@ namespace matrix{
|
||||
size_t height;
|
||||
|
||||
raii::rjp_string thumburl;
|
||||
raii::string thumbmime;
|
||||
size_t thumb_width;
|
||||
size_t thumb_height;
|
||||
size_t thumbsize;
|
||||
|
||||
Reference in New Issue
Block a user