Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Jan 26 15:07
    remioukrat closed #40
  • Jan 26 15:07
    remioukrat commented #40
  • Jan 26 12:47
    lganzzzo commented #40
  • Jan 25 14:24
    remioukrat commented #40
  • Jan 25 12:23
    lganzzzo commented #40
  • Jan 25 10:45
    lganzzzo labeled #385
  • Jan 25 10:45
    lganzzzo commented #385
  • Jan 25 10:37
    remioukrat opened #40
  • Jan 24 02:33
    formoon commented #385
  • Jan 24 02:30
    formoon opened #385
  • Jan 22 08:55
    remioukrat commented #384
  • Jan 20 23:45
    lganzzzo commented #384
  • Jan 20 17:57
    remioukrat closed #384
  • Jan 20 17:57
    remioukrat commented #384
  • Jan 20 17:39
    remioukrat edited #384
  • Jan 20 17:38
    remioukrat opened #384
  • Jan 20 13:45
    TheBestChenQiZhen reopened #383
  • Jan 20 13:42
    TheBestChenQiZhen commented #383
  • Jan 20 13:42
    TheBestChenQiZhen closed #383
  • Jan 20 13:42
    TheBestChenQiZhen commented #383
rrajpaul
@rrajpaul
@bhorn I am getting an error when trying to return a dto object from a bsoncxx::v_noabi::document using readFromDocument
@bhorn

@bhorn -- sample DTO
// StyleDto.hpp
// crud
//
// Created by Leonid on 3/13/18.
// Modified by Ryan Rajpaul 01/31/2020
// Copyright © 2018 oatpp. All rights reserved.
//

ifndef DTOs_hpp

define DTOs_hpp

include "oatpp/core/data/mapping/type/Object.hpp"

include "oatpp/core/macro/codegen.hpp"

include OATPP_CODEGEN_BEGIN(DTO)

class StyleDto : public oatpp::data::mapping::type::Object {

DTO_INIT(StyleDto, Object)

DTO_FIELD(Int32, StyleId);
DTO_FIELD(String, Manufacturer, "Manufacturer");
DTO_FIELD(String, Brand, "Brand");
DTO_FIELD(String, Category, "Category");
DTO_FIELD(String, Type, "Type");
DTO_FIELD(String, Description, "Description");

};

include OATPP_CODEGEN_END(DTO)

endif / DTOs_hpp /

@bhorn -- method below StyleDto::ObjectWrapper Database::getStyleById(v_int32 id){
bsoncxx::stdx::optional<bsoncxx::v_noabi::document::value> result =
m_db[COLLECTION_NAME].find_one({document{} << "StyleId" << id << finalize});

auto docView = result->view();
auto style = m_mongomapper->readFromDocument(docView);

if(style) {
    OATPP_LOGD(TAG, "Found style with id %d", id);

    return style;
}
return style;

}

rrajpaul
@rrajpaul

@bhorn -- Method that will try to get a mongodb document by StyleId

StyleDto::ObjectWrapper Database::getStyleById(v_int32 id){
bsoncxx::stdx::optional<bsoncxx::v_noabi::document::value> result =
m_db[COLLECTION_NAME].find_one({document{} << "StyleId" << id << finalize});

auto docView = result->view();
auto style = m_mongomapper->readFromDocument(docView);

if(style) {
    OATPP_LOGD(TAG, "Found style with id %d", id);

    return style;
}
return style;

}

@bhorn sample json definition of a style document from style collection

{
"StyleId": NumberInt(4400),
"Manufacturer": "Acme Inc",
"Category": "Boys",
"Type": "Footwear",
"Description": "Running shoes"
}

Benedikt-Alexander Mokroß
@bamkrs
Hey @rrajpaul i will take a look tomorrow, its very hard to read on mobile
rrajpaul
@rrajpaul
No problem, I will keep at it thanks
Benedikt-Alexander Mokroß
@bamkrs
Hey @rrajpaul sorry for replying so late, kinda bussy atm. Do you still have the error? could you send me a pastebin of the error and a screenshot of your stack?
rrajpaul
@rrajpaul
fix the error, my bad as I did not do readFromDocument<StyleDto::ObjectWrapper>
@bhorn the fork for oatpp-mongocxxmapper is now on my github at https://github.com/rrajpaul/oatpp-mongocxxmapper
rrajpaul
@rrajpaul
I am having a different sort of issue issue Floating point exception (core dumped) I have uploaded my local project to https://github.com/rrajpaul/oatpp-mongodb-example. If you can take a look
rrajpaul
@rrajpaul
@bhorn I have figured what is causing the error - it was swagger component
Benedikt-Alexander Mokroß
@bamkrs
@rrajpaul great to hear and see your progress! If you have any further issues, we can help you the most if you screenshot your error and stacktrace. If its too much to screenshot, you can also upload it to pastebin or similar.
rrajpaul
@rrajpaul
@bhorn I have updated the example project name to example-mongodb and i used the README.md from the CRUD example.
@bhorn I will update the tests as they do not work.
@bhorn the link to the mongodb example project is https://github.com/rrajpaul/example-mongodb
note8g2018
@note8g2018
hi
do you know how to install LibreSSL in windows 10?
Benedikt-Alexander Mokroß
@bamkrs
Hi @note8g2018 libressl has a README.windows in their repository, https://github.com/libressl-portable/portable/blob/master/README.windows I think this explains everything :)
codderembedded
@codderembedded
Hi, I am trying my-service example. I want to create an endpoint that performs file operations. I want to take base64 data, convert it to string and save it in txt file. How can I do it? How can I convert to std::string from oatpp::String?
oat++
@oatpp_io_twitter

Hello @codderembedded ,

I want to take base64 data, convert it to string and save it in txt file. How can I do it?

#include "oatpp/encoding/Base64.hpp"

...

oatpp::String base64Data = "SGVsbG8gV29ybGQh";
oatpp::String plainData = oatpp::encoding::Base64::decode(base64Data);
plainData->saveToFile("/path/to/file.txt");
How can I convert to std::string from oatpp::String?
  oatpp::String oatppString = "Hello World!";
  std::string stdString = oatppString->std_str();
Please let me know if you have more questions!
codderembedded
@codderembedded
thank you very much
codderembedded
@codderembedded
How can I convert to oatpp::String from int
oat++
@oatpp_io_twitter
Hey @codderembedded , please find the ConversionUtils.hpp - https://github.com/oatpp/oatpp/blob/master/src/oatpp/core/utils/ConversionUtils.hpp#L140
rrajpaul
@rrajpaul
@bhorn I have changed the mongodb example (https://github.com/rrajpaul/example-mongodb) to use the same dto as the crud example and I still need to update the database setup in the README.md and the update the unit test, I hoping to get it done by this Sunday
rrajpaul
@rrajpaul
@bhorn Updated the database setup and provided a script to automate the process, now doing the unit tests
@bhorn take a look and let me know if you have any suggestions
rrajpaul
@rrajpaul
How do I pass parameter for unit testing for example to test the crud method getUserById
oat++
@oatpp_io_twitter

Hello @rrajpaul ,

How do I pass parameter for unit testing for example to test the crud method getUserById

The recommended way to test oatpp controllers is described here.
The basic idea - is that you create an ApiClient for you ApiController and then you do regular HTTP calls to your server.

Please let me know if you have more questions.

Regards,
Leonid

Sanzona
@Sanzona
image.png
When i try run this sample, i got this error.
oat++
@oatpp_io_twitter

Hey @Sanzona ,

Thanks for sharing this issue. We'll have to update the documentation!

Just pass m_objectMapper variable as is without .get():

  std::shared_ptr<OutgoingResponse> handle(const std::shared_ptr<IncomingRequest>& request) override {
    auto message = MessageDto::createShared();
    message->statusCode = 1024;
    message->message = "Hello DTO!";
    return ResponseFactory::createResponse(Status::CODE_200, message, m_objectMapper);
  }
Bob Tolbert
@rwtolbert
ok, kind of a strange request, but does anyone have an example of reading a file into a DTO object?
as in a JSON file, specifically
oat++
@oatpp_io_twitter
Hello @rwtolbert
The simplest way:
    oatpp::String json = oatpp::base::StrBuffer::loadFromFile("/path/to/file");
    auto myDto = objectMapper->readFromString<MyDto>(json);
Regards,
Leonid
Bob Tolbert
@rwtolbert
thanks. From looking through the code, I figured it would be that easy, but just couldn't put the pieces together
oat++
@oatpp_io_twitter
No worries, please feel free to ping me in case of questions
Bob Tolbert
@rwtolbert
you bet
codderembedded
@codderembedded
Hi, I want to add endpoint on my-service about for create download file link. How can I do it?
oat++
@oatpp_io_twitter

Hello @codderembedded ,

As I understand you want to serve a file download. For you may do the following:

ENDPOINT("GET", "/download", download) {

  auto body = std::make_shared<oatpp::web::protocol::http::outgoing::StreamingBody>(
    std::make_shared<oatpp::data::stream::FileInputStream>("path/to/file")
  );

  return OutgoingResponse::createShared(Status::CODE_200, body);

}

Please let me know if it works for you.

Regards,
Leonid

codderembedded
@codderembedded
not exactly that. yes I want to download it to computer. But I want to create url for download. (return html_link). When I log into this link, download file
codderembedded
@codderembedded
image.png
I have other question. Here Can I reach the name of the file I uploaded? and I want to upload and save many files at the same time with the same names.
How can I do that?
oat++
@oatpp_io_twitter

Hey @codderembedded ,

not exactly that. yes I want to download it to computer. But I want to create url for download. (return html_link). When I log into this link, download file

Ok, so you have to do exactly as you said - generate a random link --> put it into let's say hash map (link to file) and once user accessed the link check in the map which file should be downloaded.

There is no out-of-the-box oatpp functionality for that.