本文整理汇总了C++中Files::attach方法的典型用法代码示例。如果您正苦于以下问题:C++ Files::attach方法的具体用法?C++ Files::attach怎么用?C++ Files::attach使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Files
的用法示例。
在下文中一共展示了Files::attach方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: upid
TEST_F(FilesTest, DownloadTest)
{
Files files;
process::UPID upid("files", process::node());
// This is a one-pixel black gif image.
const unsigned char gifData[] = {
0x47, 0x49, 0x46, 0x38, 0x37, 0x61, 0x01, 0x00, 0x01, 0x00, 0x91, 0x00,
0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x2c, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x02,
0x02, 0x4c, 0x01, 0x00, 0x3b, 0x00
};
string data((const char*) gifData, sizeof(gifData));
ASSERT_SOME(os::write("binary", "no file extension"));
ASSERT_SOME(os::write("black.gif", data));
AWAIT_EXPECT_READY(files.attach("binary", "binary"));
AWAIT_EXPECT_READY(files.attach("black.gif", "black.gif"));
Future<Response> response =
process::http::get(upid, "download.json", "path=binary");
AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response);
AWAIT_EXPECT_RESPONSE_HEADER_EQ(
"application/octet-stream",
"Content-Type",
response);
AWAIT_EXPECT_RESPONSE_BODY_EQ("no file extension", response);
response = process::http::get(upid, "download.json", "path=black.gif");
AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response);
AWAIT_EXPECT_RESPONSE_HEADER_EQ("image/gif", "Content-Type", response);
AWAIT_EXPECT_RESPONSE_BODY_EQ(data, response);
}
示例2:
TEST_F(FilesTest, DetachTest)
{
Files files;
ASSERT_SOME(os::write("file", "body"));
AWAIT_EXPECT_READY(files.attach("file", "myname"));
files.detach("myname");
files.detach("myname");
}