小编Vla*_*dac的帖子

有条件的导入/覆盖模块导入

我想将模块配置从一个模块传播到另一个模块。我发现这很难详细解释,因此我将举一个例子。

我有一个类似的模块:

@NgModule({
  declarations: [
    ButtonComponent,
    TranslatePipe,
  ],
  imports: [
    CommonModule,
  ],
  exports: [
    ButtonComponent,
  ],
})
export class ButtonModule {
  static withConfig(config: ButtonModuleConfig): ModuleWithProviders {
    return {
      ngModule: ButtonModule,
      providers: [
        {
          provide: TranslateService,
          useClass: config.translateService,
        },
      ],
    };
  }
}
Run Code Online (Sandbox Code Playgroud)

我想做这样的事情是另一个模块:

@NgModule({
  declarations: [
    PageComponent,
  ],
  imports: [
    CommonModule,
    ButtonModule, // the one defined above without overriding the TranslateService
  ],
  exports: [
    PageComponent,
  ],
})
export class PageModule {
  static withConfig(config: PageModuleConfig): ??? {
    return {
      ngModule: PageModule, …
Run Code Online (Sandbox Code Playgroud)

angular

5
推荐指数
1
解决办法
99
查看次数

使用express和multer将带有Java MultipartEntity的映像上传到Node.js服务器

我正在尝试使用自定义MultipartEntity也从Android应用程序上传图像,该自定义也会更新ProgressDialog(这也是我使用已弃用的原因MultipartEntity).
相关的Java代码:

        File file = new File(imgPath);

        HttpPost post = new HttpPost("http://" + SERVER + "/upload");

        MultipartEntity entity = new MyMultipartEntity(new MyMultipartEntity.ProgressListener()
        {
            public void transferred(long num)
            {
                publishProgress((int) ((num / (float) totalSize) * 100));
                Log.d("DEBUG", num + " - " + totalSize);
            }
        });
        ContentBody cbFile = new FileBody(file, "image/jpeg");
        entity.addPart("source", cbFile);

        totalSize = entity.getContentLength();

        post.setEntity(entity);

        HttpResponse response = client.execute(post);
        int statusCode = response.getStatusLine().getStatusCode();

        if(statusCode == HttpStatus.SC_OK){
            String fullRes = EntityUtils.toString(response.getEntity());
            Log.d("DEBUG", fullRes); …
Run Code Online (Sandbox Code Playgroud)

java android node.js express multer

3
推荐指数
1
解决办法
3000
查看次数

标签 统计

android ×1

angular ×1

express ×1

java ×1

multer ×1

node.js ×1