bool putbin ( S3ConnectionPtr aS3, const std::string& aBucketName, const std::string& aFileName, const std::string& aKey ) { try { std::ifstream lInStream(aFileName.c_str()); if (!lInStream) { std::cerr << "file not found or accessible: " << aFileName << std::endl; return false; } PutResponsePtr lPut = aS3->put(aBucketName, aKey.length()==0?aFileName:aKey, lInStream, "application/octet-stream"); } catch (PutException &e) { std::cerr << e.what() << std::endl; return false; } return true; }
static void upload_staged_image(S3ConnectionPtr s3conn, IplImage *image, const std::string& key) { assert(image->imageData != NULL); std::stringstream ins; ins << PS3M << SERIAL_DELIM << image->nChannels << SERIAL_DELIM << image->width << SERIAL_DELIM << image->height << SERIAL_DELIM << image->depth << std::endl; ins.write(image->imageData, image->imageSize); // int count = ins.gcount(); // std::cout << count << " " << image->imageData << " " << image->imageSize; // assert(count == image->imageSize); PutResponsePtr res = s3conn->put(CVDB::BUCKET, key, ins, "binary/octet-stream"); }
static void upload_image_eigen(S3ConnectionPtr s3conn, ImageMetadata *meta) { assert(meta->features != NULL); char buf[32]; std::string key(meta->imagetable->prefix); key += "/"; key += EIGEN_PREFIX; key += "/"; sprintf(buf, "%d.eigen", meta->id); key += buf; std::stringstream ins; ins.write((char*)(meta->features), sizeof(float)*meta->imagetable->eigenspace->dimension); PutResponsePtr res = s3conn->put(meta->imagetable->bucket, key, ins, "binary/octet-stream"); }